diff options
Diffstat (limited to 'test/SemaObjCXX')
-rw-r--r-- | test/SemaObjCXX/Inputs/nullability-consistency-2.h | 5 | ||||
-rw-r--r-- | test/SemaObjCXX/Inputs/nullability-consistency-6.h | 10 | ||||
-rw-r--r-- | test/SemaObjCXX/arc-system-header.mm | 4 | ||||
-rw-r--r-- | test/SemaObjCXX/arc-type-conversion.mm | 4 | ||||
-rw-r--r-- | test/SemaObjCXX/crash.mm | 8 | ||||
-rw-r--r-- | test/SemaObjCXX/cxx1y-lambda.mm | 19 | ||||
-rw-r--r-- | test/SemaObjCXX/delay-parsing-func-tryblock.mm | 9 | ||||
-rw-r--r-- | test/SemaObjCXX/exceptions.mm | 2 | ||||
-rw-r--r-- | test/SemaObjCXX/message.mm | 19 | ||||
-rw-r--r-- | test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm | 2 | ||||
-rw-r--r-- | test/SemaObjCXX/parameterized_classes_arc.mm | 119 | ||||
-rw-r--r-- | test/SemaObjCXX/property-invalid-type.mm | 4 | ||||
-rw-r--r-- | test/SemaObjCXX/property-type-mismatch.mm | 10 | ||||
-rw-r--r-- | test/SemaObjCXX/pseudo-destructor.mm | 23 | ||||
-rw-r--r-- | test/SemaObjCXX/sel-address.mm | 19 | ||||
-rw-r--r-- | test/SemaObjCXX/vararg-non-pod.mm | 9 |
16 files changed, 247 insertions, 19 deletions
diff --git a/test/SemaObjCXX/Inputs/nullability-consistency-2.h b/test/SemaObjCXX/Inputs/nullability-consistency-2.h index 4517738..5203146 100644 --- a/test/SemaObjCXX/Inputs/nullability-consistency-2.h +++ b/test/SemaObjCXX/Inputs/nullability-consistency-2.h @@ -13,4 +13,9 @@ void g3(const @property (retain,nullable) SomeClass *property2; - (nullable SomeClass *)method1; - (void)method2:(nonnull SomeClass *)param; +@property (readonly, weak) SomeClass *property3; // expected-warning{{missing a nullability type specifier}} +@end + +@interface SomeClass () +@property (readonly, weak) SomeClass *property4; // expected-warning{{missing a nullability type specifier}} @end diff --git a/test/SemaObjCXX/Inputs/nullability-consistency-6.h b/test/SemaObjCXX/Inputs/nullability-consistency-6.h index cb712e9..d1764a8 100644 --- a/test/SemaObjCXX/Inputs/nullability-consistency-6.h +++ b/test/SemaObjCXX/Inputs/nullability-consistency-6.h @@ -4,5 +4,15 @@ int *ptr; // expected-warning {{missing a nullability type specifier}} extern void **blah; // expected-warning 2{{missing a nullability type specifier}} +__attribute__((objc_root_class)) +@interface ClassWithWeakProperties +@property (readonly, weak) ClassWithWeakProperties *prop1; +@property (readonly, weak, null_unspecified) ClassWithWeakProperties *prop2; +@end + +@interface ClassWithWeakProperties () +@property (readonly, weak) ClassWithWeakProperties *prop3; +@end + #pragma clang assume_nonnull end diff --git a/test/SemaObjCXX/arc-system-header.mm b/test/SemaObjCXX/arc-system-header.mm index b97e2f3..5f5445c 100644 --- a/test/SemaObjCXX/arc-system-header.mm +++ b/test/SemaObjCXX/arc-system-header.mm @@ -4,6 +4,6 @@ void f(A* a) { a->data.void_ptr = 0; - a->data.a_b.b = 0; // expected-error{{'a_b' is unavailable: this system field has retaining ownership}} + a->data.a_b.b = 0; // expected-error{{'a_b' is unavailable in ARC}} } -// expected-note@arc-system-header.h:10{{'a_b' has been explicitly marked unavailable here}} +// expected-note@arc-system-header.h:10{{field has non-trivial ownership qualification}} diff --git a/test/SemaObjCXX/arc-type-conversion.mm b/test/SemaObjCXX/arc-type-conversion.mm index fd42513..8544726 100644 --- a/test/SemaObjCXX/arc-type-conversion.mm +++ b/test/SemaObjCXX/arc-type-conversion.mm @@ -6,8 +6,8 @@ void * cvt(id arg) // expected-note{{candidate function not viable: cannot conve void* voidp_val; (void)(int*)arg; // expected-error {{cast of an Objective-C pointer to 'int *' is disallowed with ARC}} (void)(id)arg; - (void)(__autoreleasing id*)arg; // expected-error{{C-style cast from 'id' to '__autoreleasing id *' casts away qualifiers}} - (void)(id*)arg; // expected-error{{C-style cast from 'id' to '__strong id *' casts away qualifiers}} + (void)(__autoreleasing id*)arg; // expected-error{{cast of an Objective-C pointer to '__autoreleasing id *' is disallowed with ARC}} + (void)(id*)arg; // expected-error{{cast of an Objective-C pointer to '__strong id *' is disallowed with ARC}} (void)(__autoreleasing id**)voidp_val; (void)(void*)voidp_val; diff --git a/test/SemaObjCXX/crash.mm b/test/SemaObjCXX/crash.mm index 521b923..19cf309 100644 --- a/test/SemaObjCXX/crash.mm +++ b/test/SemaObjCXX/crash.mm @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++98 %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify // <rdar://problem/11286701> namespace std { @@ -18,6 +20,8 @@ struct EvilStruct { typedef std::pair<int, int> IntegerPair; -template<typename...Ts> void f(Ts); // expected-error {{unexpanded}} expected-warning {{extension}} - +template<typename...Ts> void f(Ts); // expected-error {{unexpanded}} +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2 {{variadic templates are a C++11 extension}} +#endif @end diff --git a/test/SemaObjCXX/cxx1y-lambda.mm b/test/SemaObjCXX/cxx1y-lambda.mm new file mode 100644 index 0000000..25445cc --- /dev/null +++ b/test/SemaObjCXX/cxx1y-lambda.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++1y -Wno-unused-value -fsyntax-only -verify -fobjc-arc %s + +// expected-no-diagnostics +__attribute__((objc_root_class)) +@interface NSString +@end + +// rdar://problem/22344904 +void testResultTypeDeduction(int i) { + auto x = [i] { + switch (i) { + case 0: + return @"foo"; + + default: + return @"bar"; + } + }; +} diff --git a/test/SemaObjCXX/delay-parsing-func-tryblock.mm b/test/SemaObjCXX/delay-parsing-func-tryblock.mm index ecee7be..f6b849b 100644 --- a/test/SemaObjCXX/delay-parsing-func-tryblock.mm +++ b/test/SemaObjCXX/delay-parsing-func-tryblock.mm @@ -1,5 +1,4 @@ // RUN: %clang_cc1 -x objective-c++ -fcxx-exceptions -fsyntax-only -Werror -verify -Wno-objc-root-class %s -// expected-no-diagnostics // rdar://10387088 @interface MyClass @@ -29,13 +28,13 @@ BadReturn::BadReturn(MyClass * myObject) try : CObj(myObject) { try { [myObject privateMethod]; [myObject privateMethod1]; - getMe = bar(myObject); - [CObj privateMethod1]; + getMe = bar(myObject); // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}} + [CObj privateMethod1]; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}} } catch(int ei) { - i = ei; + i = ei; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}} } catch(...) { { - i = 0; + i = 0; // expected-error {{cannot refer to a non-static member from the handler of a constructor function try block}} } } } diff --git a/test/SemaObjCXX/exceptions.mm b/test/SemaObjCXX/exceptions.mm index 37e6def..78a9a9e 100644 --- a/test/SemaObjCXX/exceptions.mm +++ b/test/SemaObjCXX/exceptions.mm @@ -5,7 +5,7 @@ namespace test0 { void test() { try { - } catch (NSException e) { // expected-error {{can't catch an Objective-C object by value}} + } catch (NSException e) { // expected-error {{cannot catch an Objective-C object by value}} } } } diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm index 7d8520c..e2bdd13 100644 --- a/test/SemaObjCXX/message.mm +++ b/test/SemaObjCXX/message.mm @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++11 %s + @interface I1 - (int*)method; @end @@ -62,15 +65,25 @@ struct identity { // or typename-specifiers. if (false) { if (true) - return [typename identity<I3>::type method]; // expected-warning{{occurs outside of a template}} + return [typename identity<I3>::type method]; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif return [::I3 method]; } int* ip1 = {[super method]}; int* ip2 = {[::I3 method]}; - int* ip3 = {[typename identity<I3>::type method]}; // expected-warning{{occurs outside of a template}} - int* ip4 = {[typename identity<I2_holder>::type().get() method]}; // expected-warning{{occurs outside of a template}} + int* ip3 = {[typename identity<I3>::type method]}; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif + + int* ip4 = {[typename identity<I2_holder>::type().get() method]}; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif int array[5] = {[3] = 2}; return [super method]; } diff --git a/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm b/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm index 375b955..3b590c4 100644 --- a/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm +++ b/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm @@ -48,7 +48,7 @@ struct BOXABLE NonTriviallyCopyable { void checkNSValueDiagnostic() { NSRect rect; - id value = @(rect); // expected-error{{NSValue must be available to use Objective-C boxed expressions}} + id value = @(rect); // expected-error{{definition of class NSValue must be available to use Objective-C boxed expressions}} } @interface NSValue diff --git a/test/SemaObjCXX/parameterized_classes_arc.mm b/test/SemaObjCXX/parameterized_classes_arc.mm new file mode 100644 index 0000000..38ddd70 --- /dev/null +++ b/test/SemaObjCXX/parameterized_classes_arc.mm @@ -0,0 +1,119 @@ +// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak %s -verify + +// rdar://21612439 + +__attribute__((objc_root_class)) +@interface NSObject +@end + +@class Forward; +@class Forward2; + +// Tests for generic arguments. + +@interface PC1<T> : NSObject +- (T) get; +- (void) set: (T) v; +@end + +void test1a(PC1<__weak id> *obj) { // expected-error {{type argument '__weak id' cannot be qualified with '__weak'}} + id x = [obj get]; + [obj set: x]; +} + +void test1b(PC1<__strong id> *obj) { // expected-error {{type argument '__strong id' cannot be qualified with '__strong'}} + id x = [obj get]; + [obj set: x]; +} + +void test1c(PC1<id> *obj) { + id x = [obj get]; + [obj set: x]; +} + +// Test that this doesn't completely kill downstream type-checking. +void test1d(PC1<__weak Forward*> *obj) { // expected-error {{type argument 'Forward *__weak' cannot be qualified with '__weak'}} + Forward2 *x = [obj get]; // expected-error {{cannot initialize}} + [obj set: x]; +} + +void test1e(PC1<__strong Forward*> *obj) { // expected-error {{type argument 'Forward *__strong' cannot be qualified with '__strong'}} + Forward2 *x = [obj get]; // expected-error {{cannot initialize}} + [obj set: x]; +} + +void test1f(PC1<Forward*> *obj) { + Forward2 *x = [obj get]; // expected-error {{cannot initialize}} + [obj set: x]; +} + +// Typedefs are fine, just silently ignore them. +typedef __strong id StrongID; +void test1g(PC1<StrongID> *obj) { + Forward2 *x = [obj get]; + [obj set: x]; +} + +typedef __strong Forward *StrongForward; +void test1h(PC1<StrongForward> *obj) { + Forward2 *x = [obj get]; // expected-error {{cannot initialize}} + [obj set: x]; +} + +// These aren't really ARC-specific, but they're the same basic idea. +void test1i(PC1<const id> *obj) { // expected-error {{type argument 'const id' cannot be qualified with 'const'}} + id x = [obj get]; + [obj set: x]; +} + +void test1j(PC1<volatile id> *obj) { // expected-error {{type argument 'volatile id' cannot be qualified with 'volatile'}} + id x = [obj get]; + [obj set: x]; +} + +void test1k(PC1<__attribute__((address_space(256))) id> *obj) { // expected-error {{type argument '__attribute__((address_space(256))) id' cannot be qualified with '__attribute__((address_space(256)))'}} + id x = [obj get]; + [obj set: x]; +} + +// Template-specific tests. +template <class T> PC1<T> *test2_temp(); +void test2a() { test2_temp<id>(); } +void test2b() { test2_temp<const id>(); } +void test2c() { test2_temp<volatile id>(); } +void test2d() { test2_temp<__strong id>(); } +void test2e() { test2_temp<__weak id>(); } +void test2f() { test2_temp<__attribute__((address_space(256))) id>(); } + +template <class T> PC1<const T> *test3a(); // expected-error {{type argument 'const T' cannot be qualified with 'const'}} +template <class T> PC1<__strong T> *test3b(); // expected-error {{type argument '__strong T' cannot be qualified with '__strong'}} + +// Tests for generic parameter bounds. + +@interface PC2<T : __strong id> // expected-error {{type bound '__strong id' for type parameter 'T' cannot be qualified with '__strong'}} +@end + +@interface PC3<T : __weak id> // expected-error {{type bound '__weak id' for type parameter 'T' cannot be qualified with '__weak'}} +@end + +@interface PC4<T : __strong Forward*> // expected-error {{type bound 'Forward *__strong' for type parameter 'T' cannot be qualified with '__strong'}} +@end + +@interface PC5<T : __weak Forward*> // expected-error {{type bound 'Forward *__weak' for type parameter 'T' cannot be qualified with '__weak'}} +@end + +@interface PC6<T : StrongID> // expected-error {{type bound 'StrongID' (aka '__strong id') for type parameter 'T' cannot be qualified with '__strong'}} +@end + +@interface PC7<T : StrongForward> // expected-error {{type bound 'StrongForward' (aka 'Forward *__strong') for type parameter 'T' cannot be qualified with '__strong'}} +@end + +// These aren't really ARC-specific, but they're the same basic idea. +@interface PC8<T : const id> // expected-error {{type bound 'const id' for type parameter 'T' cannot be qualified with 'const'}} +@end + +@interface PC9<T : volatile id> // expected-error {{type bound 'volatile id' for type parameter 'T' cannot be qualified with 'volatile'}} +@end + +@interface PC10<T : __attribute__((address_space(256))) id> // expected-error {{type bound '__attribute__((address_space(256))) id' for type parameter 'T' cannot be qualified with '__attribute__((address_space(256)))'}} +@end diff --git a/test/SemaObjCXX/property-invalid-type.mm b/test/SemaObjCXX/property-invalid-type.mm index 5b8a848..6482358 100644 --- a/test/SemaObjCXX/property-invalid-type.mm +++ b/test/SemaObjCXX/property-invalid-type.mm @@ -13,11 +13,11 @@ @synthesize response; - (void) foo :(A*) a // expected-error {{expected a type}} { - self.response = a; + self.response = a; // expected-error{{assigning to 'int *' from incompatible type 'id'}} } @end void foo(I *i) { - i.helper; + i.helper; // expected-warning{{property access result unused - getters should not be used for side effects}} } diff --git a/test/SemaObjCXX/property-type-mismatch.mm b/test/SemaObjCXX/property-type-mismatch.mm index 2b267ad..6ab07b8 100644 --- a/test/SemaObjCXX/property-type-mismatch.mm +++ b/test/SemaObjCXX/property-type-mismatch.mm @@ -18,3 +18,13 @@ @property (assign) NSObject<P2> *prop; @end +@interface C<T> : NSObject +@end + +@interface D +@property (nonatomic,readonly,nonnull) C<D *> *property; +@end + +@interface D () +@property (nonatomic, setter=_setProperty:) C *property; // okay +@end diff --git a/test/SemaObjCXX/pseudo-destructor.mm b/test/SemaObjCXX/pseudo-destructor.mm new file mode 100644 index 0000000..06570c1 --- /dev/null +++ b/test/SemaObjCXX/pseudo-destructor.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// expected-no-diagnostics + +__attribute__((objc_root_class)) +@interface Root +@end + +@class Forward; + +template <class T> void destroyPointer(T *t) { + t->~T(); +} + +template <class T> void destroyReference(T &t) { + t.~T(); +} + +template void destroyPointer<Root*>(Root **); +template void destroyReference<Root*>(Root *&); + +// rdar://18522255 +template void destroyPointer<Forward*>(Forward **); +template void destroyReference<Forward*>(Forward *&); diff --git a/test/SemaObjCXX/sel-address.mm b/test/SemaObjCXX/sel-address.mm new file mode 100644 index 0000000..a1209ab --- /dev/null +++ b/test/SemaObjCXX/sel-address.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// pr7390 + +void f(const SEL& v2) {} +void g(SEL* _Nonnull); +void h() { + f(@selector(dealloc)); + + SEL s = @selector(dealloc); + SEL* ps = &s; + + @selector(dealloc) = s; // expected-error {{expression is not assignable}} + + SEL* ps2 = &@selector(dealloc); + + // Shouldn't crash. + g(&@selector(foo)); +} + diff --git a/test/SemaObjCXX/vararg-non-pod.mm b/test/SemaObjCXX/vararg-non-pod.mm index 5a6281d..daf9aa9 100644 --- a/test/SemaObjCXX/vararg-non-pod.mm +++ b/test/SemaObjCXX/vararg-non-pod.mm @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++11 extern char version[]; @@ -17,7 +19,12 @@ void t1(D *d) { C c(10); - [d g:10, c]; // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}} + [d g:10, c]; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}} +#else + // expected-no-diagnostics@-4 +#endif [d g:10, version]; } |