Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/DiagnosticsClangImporter.def
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ ERROR(redundant_conformance_protocol,none,
"redundant conformance of %0 to protocol '%1'", (Type, StringRef))

WARNING(returns_retained_or_returns_unretained_for_non_cxx_frt_values, none,
"%0 should not be annotated with SWIFT_TURNS_RETAINED or "
"%0 should not be annotated with SWIFT_RETURNS_RETAINED or "
"SWIFT_RETURNS_UNRETAINED because it is not returning "
"a SWIFT_SHARED_REFERENCE type",
(const clang::NamedDecl *))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,38 +191,38 @@ FRTStruct *_Nonnull global_function_returning_cxx_frt_with_annotations()
// C++ APIs returning non-cxx-frts (for testing diagnostics)
struct StructWithAPIsReturningNonCxxFrt {
static NonFRTStruct *_Nonnull StaticMethodReturningNonCxxFrt();
static NonFRTStruct *_Nonnull StaticMethodReturningNonCxxFrtWithAnnotation() // expected-warning {{'StaticMethodReturningNonCxxFrtWithAnnotation' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
static NonFRTStruct *_Nonnull StaticMethodReturningNonCxxFrtWithAnnotation() // expected-warning {{'StaticMethodReturningNonCxxFrtWithAnnotation' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));
};

NonFRTStruct *_Nonnull global_function_returning_non_cxx_frt();
NonFRTStruct *_Nonnull global_function_returning_non_cxx_frt_with_annotations() // expected-warning {{'global_function_returning_non_cxx_frt_with_annotations' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
NonFRTStruct *_Nonnull global_function_returning_non_cxx_frt_with_annotations() // expected-warning {{'global_function_returning_non_cxx_frt_with_annotations' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));

// C++ APIs returning SWIFT_IMMORTAL_REFERENCE types (for testing diagnostics)
struct StructWithAPIsReturningImmortalReference {
static ImmortalRefStruct *_Nonnull StaticMethodReturningImmortalReference();
static ImmortalRefStruct
*_Nonnull StaticMethodReturningImmortalReferenceWithAnnotation() // expected-warning {{'StaticMethodReturningImmortalReferenceWithAnnotation' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
*_Nonnull StaticMethodReturningImmortalReferenceWithAnnotation() // expected-warning {{'StaticMethodReturningImmortalReferenceWithAnnotation' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));
};

ImmortalRefStruct *_Nonnull global_function_returning_immortal_reference();
ImmortalRefStruct
*_Nonnull global_function_returning_immortal_reference_with_annotations() // expected-warning {{'global_function_returning_immortal_reference_with_annotations' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
*_Nonnull global_function_returning_immortal_reference_with_annotations() // expected-warning {{'global_function_returning_immortal_reference_with_annotations' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));

// C++ APIs returning SWIFT_UNSAFE_REFERENCE types (for testing diagnostics)
struct StructWithAPIsReturningUnsafeReference {
static UnsafeRefStruct *_Nonnull StaticMethodReturningUnsafeReference();
static UnsafeRefStruct
*_Nonnull StaticMethodReturningUnsafeReferenceWithAnnotation() // expected-warning {{'StaticMethodReturningUnsafeReferenceWithAnnotation' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
*_Nonnull StaticMethodReturningUnsafeReferenceWithAnnotation() // expected-warning {{'StaticMethodReturningUnsafeReferenceWithAnnotation' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));
};

UnsafeRefStruct *_Nonnull global_function_returning_unsafe_reference();
UnsafeRefStruct
*_Nonnull global_function_returning_unsafe_reference_with_annotations() // expected-warning {{'global_function_returning_unsafe_reference_with_annotations' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
*_Nonnull global_function_returning_unsafe_reference_with_annotations() // expected-warning {{'global_function_returning_unsafe_reference_with_annotations' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));

// Global/free C++ functions returning non-FRT
Expand Down
2 changes: 1 addition & 1 deletion test/Interop/Cxx/objc-correctness/Inputs/cxx-frt.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void releaseCxxRefType(CxxRefType *_Nonnull b) {}
+ (struct CxxRefType *)objCMethodReturningFRTBothAnnotations // expected-error {{'objCMethodReturningFRTBothAnnotations' cannot be annotated with both SWIFT_RETURNS_RETAINED and SWIFT_RETURNS_UNRETAINED}}
__attribute__((swift_attr("returns_unretained")))
__attribute__((swift_attr("returns_retained")));
+ (struct CxxValType *)objCMethodReturningNonCxxFrtAnannotated // expected-warning {{'objCMethodReturningNonCxxFrtAnannotated' should not be annotated with SWIFT_TURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
+ (struct CxxValType *)objCMethodReturningNonCxxFrtAnannotated // expected-warning {{'objCMethodReturningNonCxxFrtAnannotated' should not be annotated with SWIFT_RETURNS_RETAINED or SWIFT_RETURNS_UNRETAINED because it is not returning a SWIFT_SHARED_REFERENCE type}}
__attribute__((swift_attr("returns_retained")));

@end
Expand Down