Source-Changes-HG archive

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

[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: demonstrate empty stat...



details:   https://anonhg.NetBSD.org/src/rev/5e53edea9fd3
branches:  trunk
changeset: 377238:5e53edea9fd3
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 02 22:50:18 2023 +0000

description:
tests/lint: demonstrate empty statement in GCC statement expression

Seen in external/mit/xorg/lib/dri.old.

diffstat:

 tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r b4ba0b98c2fa -r 5e53edea9fd3 tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c
--- a/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c    Sun Jul 02 21:37:49 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c    Sun Jul 02 22:50:18 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_gcc_compound_statements1.c,v 1.12 2023/03/28 14:44:34 rillig Exp $   */
+/*     $NetBSD: d_gcc_compound_statements1.c,v 1.13 2023/07/02 22:50:18 rillig Exp $   */
 # 3 "d_gcc_compound_statements1.c"
 
 /* GCC compound statement with expression */
@@ -65,3 +65,19 @@ crash(void)
                ;
        });
 }
+
+/*
+ * 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.
+ */
+unsigned int
+empty_statement(void)
+{
+       return ({
+               unsigned int mega = 1 << 20;
+               /* expect+1: error: syntax error ';' [249] */
+               ;
+               mega;
+       });
+}



Home | Main Index | Thread Index | Old Index