From cc260beb2b3cec7f5f8db9b32568539c61e48760 Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 2 Jul 2023 22:50:18 +0000 Subject: tests/lint: demonstrate empty statement in GCC statement expression Seen in external/mit/xorg/lib/dri.old. --- tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c b/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c index 451f8446da3..1e17d133272 100644 --- a/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c +++ b/tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c @@ -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; + }); +} -- cgit