1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2// RUN: %clang_cc1 -std=c++98 -fsyntax-only -verify -Wno-objc-root-class %s 3 4#if __has_feature(objc_c_static_assert) 5#error failed 6#endif 7#if !__has_extension(objc_c_static_assert) 8#error failed 9#endif 10 11#if __cplusplus >= 201103L 12 13#if !__has_feature(objc_cxx_static_assert) 14#error failed 15#endif 16 17// C++11 18 19@interface A { 20 int a; 21 static_assert(1, ""); 22 _Static_assert(1, ""); 23 24 static_assert(0, ""); // expected-error {{static assertion failed}} 25 _Static_assert(0, ""); // expected-error {{static assertion failed}} 26 27 static_assert(a, ""); // expected-error {{static assertion expression is not an integral constant expression}} 28 static_assert(sizeof(a) == 4, ""); 29 static_assert(sizeof(a) == 3, ""); // expected-error {{static assertion failed}} \ 30 // expected-note {{evaluates to '4 == 3'}} 31} 32 33static_assert(1, ""); 34_Static_assert(1, ""); 35 36- (void)f; 37@end 38 39@implementation A { 40 int b; 41 static_assert(1, ""); 42 _Static_assert(1, ""); 43 static_assert(sizeof(b) == 4, ""); 44 static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion failed}} \ 45 // expected-note {{evaluates to '4 == 3'}} 46} 47 48static_assert(1, ""); 49 50- (void)f { 51 static_assert(1, ""); 52} 53@end 54 55@interface B 56@end 57 58@interface B () { 59 int b; 60 static_assert(sizeof(b) == 4, ""); 61 static_assert(sizeof(b) == 3, ""); // expected-error {{static assertion failed}} \ 62 // expected-note {{evaluates to '4 == 3'}} 63} 64@end 65 66#else 67 68#if __has_feature(objc_cxx_static_assert) 69#error failed 70#endif 71 72// C++98 73@interface A { 74 int a; 75 static_assert(1, ""); // expected-error {{type name requires a specifier or qualifier}} expected-error{{expected parameter declarator}} expected-error {{expected ')'}} expected-note {{to match this '('}} 76 _Static_assert(1, ""); 77 _Static_assert(0, ""); // expected-error {{static assertion failed}} 78} 79@end 80#endif 81