[BACK]Return to d_gcc_compound_statements1.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / tests / usr.bin / xlint / lint1

Annotation of src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c, Revision 1.7

1.7     ! rillig      1: /*     $NetBSD: d_gcc_compound_statements1.c,v 1.6 2021/06/20 11:42:26 rillig Exp $    */
1.2       rillig      2: # 3 "d_gcc_compound_statements1.c"
                      3:
1.4       rillig      4: /* GCC compound statement with expression */
1.1       jruoho      5:
                      6: foo(unsigned long z)
                      7: {
1.3       rillig      8:        z = ({
                      9:                unsigned long tmp;
                     10:                tmp = 1;
                     11:                tmp;
                     12:        });
1.1       jruoho     13:        foo(z);
                     14: }
1.5       rillig     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 = ({
1.7     ! rillig     23:        /* expect+1: error: syntax error 'return outside function' [249] */
        !            24:        return 3;
        !            25: });
        !            26: /* expect-1: error: cannot initialize 'int' from 'void' [185] */
1.6       rillig     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:        ({
1.7     ! rillig     36:                /* expect+1: error: type 'int' does not have member 'e' [101] */
        !            37:                0->e;
1.6       rillig     38:        });
                     39: }

CVSweb <webmaster@jp.NetBSD.org>