1 /* $NetBSD: c23.c,v 1.7 2023/07/28 22:05:44 rillig Exp $ */ 2 # 3 "c23.c" 3 4 // Tests for the option -Ac23, which allows features from C23 and all earlier 5 // ISO standards, but none of the GNU extensions. 6 // 7 // See also: 8 // c11.c 9 // msg_353.c for empty initializer braces 10 11 /* lint1-flags: -Ac23 -w -X 351 */ 12 13 int 14 empty_initializer_braces(void) 15 { 16 struct s { 17 int member; 18 } s; 19 20 // Empty initializer braces were introduced in C23. 21 s = (struct s){}; 22 s = (struct s){s.member}; 23 return s.member; 24 } 25 26 27 _Static_assert(1 > 0, "string"); 28 _Static_assert(1 > 0); 29 30 31 // The keyword 'thread_local' was introduced in C23. 32 thread_local int globally_visible; 33 34 // Thread-local functions don't make sense; lint allows them, though. 35 thread_local void 36 thread_local_function(void) 37 { 38 } 39 40 void 41 function(void) 42 { 43 // Not sure whether it makes sense to have a function-scoped 44 // thread-local variable. Don't warn for now, let the compilers handle 45 // this case. 46 thread_local int function_scoped_thread_local; 47 } 48 49 // 'thread_local' can be combined with 'extern' and 'static', but with no other 50 // storage classes. The other storage classes cannot be combined. 51 extern thread_local int extern_thread_local_1; 52 thread_local extern int extern_thread_local_2; 53 static thread_local int static_thread_local_1; 54 thread_local static int static_thread_local_2; 55 /* expect-2: warning: static variable 'static_thread_local_1' unused [226] */ 56 /* expect-2: warning: static variable 'static_thread_local_2' unused [226] */ 57