diff --git a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c index db6104ca9eb9..6cd32f89daf7 100644 --- a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c +++ b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c @@ -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; + } +} diff --git a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp index 8eb38b00dafc..4f8f75a5a75f 100644 --- a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp +++ b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp @@ -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]