Home | History | Annotate | Line # | Download | only in lint1
c23.c revision 1.2
      1 /*	$NetBSD: c23.c,v 1.2 2023/07/13 20:30:21 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 //	msg_353.c
      9 
     10 /* lint1-flags: -Ac23 -w -X 351 */
     11 
     12 int
     13 c23(void)
     14 {
     15 	struct s {
     16 		int member;
     17 	} s;
     18 
     19 	// Empty initializer braces were introduced in C23.
     20 	s = (struct s){};
     21 	s = (struct s){s.member};
     22 	return s.member;
     23 }
     24 
     25 // The keyword 'thread_local' was introduced in C23.
     26 thread_local int globally_visible;
     27 
     28 // Thread-local functions don't make sense; they are syntactically allowed,
     29 // though.
     30 thread_local void
     31 thread_local_function(void)
     32 {
     33 }
     34 
     35 void
     36 function(void)
     37 {
     38 	// Not sure whether it makes sense to have a function-scoped
     39 	// thread-local variable.  Don't warn for now, let the compilers handle
     40 	// this case.
     41 	thread_local int function_scoped_thread_local;
     42 }
     43