Home | History | Annotate | Line # | Download | only in lint1
d_gcc_compound_statements1.c revision 1.7
      1 /*	$NetBSD: d_gcc_compound_statements1.c,v 1.7 2022/01/15 14:22:03 rillig Exp $	*/
      2 # 3 "d_gcc_compound_statements1.c"
      3 
      4 /* GCC compound statement with expression */
      5 
      6 foo(unsigned long z)
      7 {
      8 	z = ({
      9 		unsigned long tmp;
     10 		tmp = 1;
     11 		tmp;
     12 	});
     13 	foo(z);
     14 }
     15 
     16 /*
     17  * Compound statements are only allowed in functions, not at file scope.
     18  *
     19  * Before decl.c 1.186 from 2021-06-19, lint crashed with a segmentation
     20  * fault.
     21  */
     22 int c = ({
     23 	/* expect+1: error: syntax error 'return outside function' [249] */
     24 	return 3;
     25 });
     26 /* expect-1: error: cannot initialize 'int' from 'void' [185] */
     27 
     28 void
     29 function(void)
     30 {
     31 	/*
     32 	 * Before cgram.y 1.229 from 2021-06-20, lint crashed due to the
     33 	 * syntax error, which made an expression NULL.
     34 	 */
     35 	({
     36 		/* expect+1: error: type 'int' does not have member 'e' [101] */
     37 		0->e;
     38 	});
     39 }
     40