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