Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint1 lint: allow empty statements in GCC stat...



details:   https://anonhg.NetBSD.org/src/rev/84b37bdf862c
branches:  trunk
changeset: 377239:84b37bdf862c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 02 22:56:13 2023 +0000

description:
lint: allow empty statements in GCC statement expressions

diffstat:

 tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c |  10 ++++------
 usr.bin/xlint/lint1/cgram.y                            |   8 ++++++--
 2 files changed, 10 insertions(+), 8 deletions(-)

diffs (65 lines):

diff -r 5e53edea9fd3 -r 84b37bdf862c tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
--- a/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c    Sun Jul 02 22:50:18 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c    Sun Jul 02 22:56:13 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_gcc_compound_statements1.c,v 1.13 2023/07/02 22:50:18 rillig Exp $   */
+/*     $NetBSD: d_gcc_compound_statements1.c,v 1.14 2023/07/02 22:56:13 rillig Exp $   */
 # 3 "d_gcc_compound_statements1.c"
 
 /* GCC compound statement with expression */
@@ -61,22 +61,20 @@ crash(void)
         * pointer in do_statement_expr.
         */
        ({
-               /* expect+1: error: syntax error ';' [249] */
                ;
        });
 }
 
 /*
- * Before 2023-07-03, lint did not accept empty statements in GCC statement
- * expressions.  These empty statements can be generated by a disabled 'assert'
- * macro.
+ * Before cgram.y 1.445 from 2023-07-03, lint did not accept empty statements
+ * in GCC statement expressions.  These empty statements can be generated by a
+ * disabled 'assert' macro.
  */
 unsigned int
 empty_statement(void)
 {
        return ({
                unsigned int mega = 1 << 20;
-               /* expect+1: error: syntax error ';' [249] */
                ;
                mega;
        });
diff -r 5e53edea9fd3 -r 84b37bdf862c usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y       Sun Jul 02 22:50:18 2023 +0000
+++ b/usr.bin/xlint/lint1/cgram.y       Sun Jul 02 22:56:13 2023 +0000
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.444 2023/07/02 18:28:15 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.445 2023/07/02 22:56:13 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID)
-__RCSID("$NetBSD: cgram.y,v 1.444 2023/07/02 18:28:15 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.445 2023/07/02 22:56:13 rillig Exp $");
 #endif
 
 #include <limits.h>
@@ -501,6 +501,10 @@ gcc_statement_expr_item:
                $$ = expr_alloc_tnode();
                $$->tn_type = gettyp(VOID);
          }
+       | T_SEMI {
+               $$ = expr_alloc_tnode();
+               $$->tn_type = gettyp(VOID);
+         }
        | expression T_SEMI {
                if ($1 == NULL) {       /* in case of syntax errors */
                        $$ = expr_alloc_tnode();



Home | Main Index | Thread Index | Old Index