Module Name: src
Committed By: rillig
Date: Sun Jul 2 22:56:13 UTC 2023
Modified Files:
src/tests/usr.bin/xlint/lint1: d_gcc_compound_statements1.c
src/usr.bin/xlint/lint1: cgram.y
Log Message:
lint: allow empty statements in GCC statement expressions
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 \
src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
cvs rdiff -u -r1.444 -r1.445 src/usr.bin/xlint/lint1/cgram.y
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
diff -u src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c:1.13 src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c:1.14
--- src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c:1.13 Sun Jul 2 22:50:18 2023
+++ src/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c Sun Jul 2 22:56:13 2023
@@ -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;
});
Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.444 src/usr.bin/xlint/lint1/cgram.y:1.445
--- src/usr.bin/xlint/lint1/cgram.y:1.444 Sun Jul 2 18:28:15 2023
+++ src/usr.bin/xlint/lint1/cgram.y Sun Jul 2 22:56:13 2023
@@ -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();