summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorrillig <rillig@NetBSD.org>2023-07-02 22:50:18 +0000
committerrillig <rillig@NetBSD.org>2023-07-02 22:50:18 +0000
commitcc260beb2b3cec7f5f8db9b32568539c61e48760 (patch)
tree1fad5251fab5909cc9ec2a5a35e72012c3264650 /tests
parentcc20041b8573aab3af35cb868804d4ec4c6fb722 (diff)
tests/lint: demonstrate empty statement in GCC statement expression
Seen in external/mit/xorg/lib/dri.old.
Diffstat (limited to 'tests')
-rw-r--r--tests/usr.bin/xlint/lint1/d_gcc_compound_statements1.c18
1 files changed, 17 insertions, 1 deletions
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;
+ });
+}