[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Parser / objc-static-assert.m
blobb16405787d57b9b1751883a5de6a30e8b07ee4b0
1 // RUN: %clang_cc1 -fobjc-runtime=macosx-fragile -fsyntax-only -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -std=c89 -fobjc-runtime=macosx-fragile -fsyntax-only -verify -Wno-objc-root-class %s
5 #if __STDC_VERSION__ >= 201112L
7 #if !__has_feature(objc_c_static_assert)
8 #error failed
9 #endif
11 #if !__has_extension(objc_c_static_assert)
12 #error failed
13 #endif
15 @interface A {
16   int a;
17   _Static_assert(1, "");
18   _Static_assert(0, ""); // expected-error {{static assertion failed}}
20   _Static_assert(a, ""); // expected-error {{use of undeclared identifier 'a'}}
21   _Static_assert(sizeof(a), ""); // expected-error {{use of undeclared identifier 'a'}}
24 _Static_assert(1, "");
26 @end
28 struct S {
29   @defs(A);
32 #else
34 // _Static_assert is available before C11 as an extension, but -pedantic
35 // warns on it.
36 #if __has_feature(objc_c_static_assert)
37 #error failed
38 #endif
40 #if !__has_extension(objc_c_static_assert)
41 #error failed
42 #endif
44 @interface A {
45   int a;
46   _Static_assert(1, "");
47   _Static_assert(0, ""); // expected-error {{static assertion failed}}
50 _Static_assert(1, "");
52 @end
54 #endif