55 lines · plain
1// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile -fsyntax-only -verify -Wno-objc-root-class %s2// RUN: %clang_cc1 -std=c89 -fobjc-runtime=macosx-fragile -fsyntax-only -verify -Wno-objc-root-class %s3 4 5#if __STDC_VERSION__ >= 201112L6 7#if !__has_feature(objc_c_static_assert)8#error failed9#endif10 11#if !__has_extension(objc_c_static_assert)12#error failed13#endif14 15@interface A {16 int a;17 _Static_assert(1, "");18 _Static_assert(0, ""); // expected-error {{static assertion failed}}19 20 _Static_assert(a, ""); // expected-error {{use of undeclared identifier 'a'}}21 _Static_assert(sizeof(a), ""); // expected-error {{use of undeclared identifier 'a'}}22}23 24_Static_assert(1, "");25 26@end27 28struct S {29 @defs(A);30};31 32#else33 34// _Static_assert is available before C11 as an extension, but -pedantic35// warns on it.36#if __has_feature(objc_c_static_assert)37#error failed38#endif39 40#if !__has_extension(objc_c_static_assert)41#error failed42#endif43 44@interface A {45 int a;46 _Static_assert(1, "");47 _Static_assert(0, ""); // expected-error {{static assertion failed}}48}49 50_Static_assert(1, "");51 52@end53 54#endif55