diff options
Diffstat (limited to 'clang/test/SemaObjCXX')
-rw-r--r-- | clang/test/SemaObjCXX/Inputs/nullability-pragmas-generics-1.h | 21 | ||||
-rw-r--r-- | clang/test/SemaObjCXX/nullability-pragmas.mm | 12 |
2 files changed, 33 insertions, 0 deletions
diff --git a/clang/test/SemaObjCXX/Inputs/nullability-pragmas-generics-1.h b/clang/test/SemaObjCXX/Inputs/nullability-pragmas-generics-1.h new file mode 100644 index 00000000000..9a51fa1e990 --- /dev/null +++ b/clang/test/SemaObjCXX/Inputs/nullability-pragmas-generics-1.h @@ -0,0 +1,21 @@ +#pragma clang assume_nonnull begin + +__attribute__((objc_root_class)) +@interface B +@end + +@interface C : B +@end + +__attribute__((objc_root_class)) +@interface NSGeneric<T : B *> // expected-note{{type parameter 'T' declared here}} +- (T)tee; +- (nullable T)maybeTee; +@end + +typedef NSGeneric<C *> *Generic_with_C; + +#pragma clang assume_nonnull end + +@interface NSGeneric<T : C *>(Blah) // expected-error{{type bound 'C *' for type parameter 'T' conflicts with previous bound 'B *'}} +@end diff --git a/clang/test/SemaObjCXX/nullability-pragmas.mm b/clang/test/SemaObjCXX/nullability-pragmas.mm index dbf4f37f401..817d056a14a 100644 --- a/clang/test/SemaObjCXX/nullability-pragmas.mm +++ b/clang/test/SemaObjCXX/nullability-pragmas.mm @@ -2,6 +2,7 @@ #include "nullability-pragmas-1.h" #include "nullability-pragmas-2.h" +#include "nullability-pragmas-generics-1.h" #if !__has_feature(assume_nonnull) # error assume_nonnull feature is not set @@ -43,3 +44,14 @@ void test_pragmas_1(A * _Nonnull a, AA * _Nonnull aa) { ptr = aa->ivar1; // expected-error{{from incompatible type 'id'}} ptr = aa->ivar2; // expected-error{{from incompatible type 'id _Nonnull'}} } + +void test_pragmas_generics(void) { + float *fp; + + NSGeneric<C *> *genC; + fp = [genC tee]; // expected-error{{from incompatible type 'C *'}} + fp = [genC maybeTee]; // expected-error{{from incompatible type 'C * _Nullable'}} + + Generic_with_C genC2; + fp = genC2; // expected-error{{from incompatible type 'Generic_with_C' (aka 'NSGeneric<C *> *')}} +} |