Module Name: src Committed By: rillig Date: Thu Apr 28 07:10:39 UTC 2022
Modified Files: src/tests/usr.bin/xlint/lint1: gcc_attribute_stmt.c gcc_attribute_stmt.exp Log Message: tests/lint: add test for GCC unused statement Seen in xsrc/LRGB.c:799. Even though it looks like this lint error may have been introduced by cgram.y 1.400 from 2022-04-24 (since LRGB.c has been unchanged for a month), earlier versions of lint produce the same parse errors. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c \ src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp 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/gcc_attribute_stmt.c diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c:1.2 --- src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c:1.1 Tue Jul 6 17:33:07 2021 +++ src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c Thu Apr 28 07:10:39 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: gcc_attribute_stmt.c,v 1.1 2021/07/06 17:33:07 rillig Exp $ */ +/* $NetBSD: gcc_attribute_stmt.c,v 1.2 2022/04/28 07:10:39 rillig Exp $ */ # 3 "gcc_attribute_stmt.c" /* @@ -34,3 +34,24 @@ attribute_fallthrough(int i) __attribute__((__fallthrough__)); } } + +/* + * Despite being undocumented, GCC 10 accepts __attribute__((__unused__)) + * at the beginning of a statement. + */ +void +unused_statements(int x) +{ + switch (x) { + case 3: + __attribute__((__unused__)) + /* expect+1: error: syntax error 'break' [249] */ + break; + case 4: + goto label; + label: + __attribute__((__unused__)) + /* expect+1: error: syntax error 'return' [249] */ + return; + } +} Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp:1.2 --- src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp:1.1 Tue Jul 6 17:33:07 2021 +++ src/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp Thu Apr 28 07:10:39 2022 @@ -1 +1,3 @@ gcc_attribute_stmt.c(34): error: syntax error '__attribute__' [249] +gcc_attribute_stmt.c(49): error: syntax error 'break' [249] +gcc_attribute_stmt.c(55): error: syntax error 'return' [249]