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: add test for GCC unuse...



details:   https://anonhg.NetBSD.org/src/rev/d3d44968969c
branches:  trunk
changeset: 365846:d3d44968969c
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Apr 28 07:10:39 2022 +0000

description:
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.

diffstat:

 tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c   |  23 ++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp |   2 ++
 2 files changed, 24 insertions(+), 1 deletions(-)

diffs (41 lines):

diff -r 40af7af996e2 -r d3d44968969c tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c    Thu Apr 28 07:08:38 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.c    Thu Apr 28 07:10:39 2022 +0000
@@ -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__));
        }
 }
+
+/*
+ * 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 -r 40af7af996e2 -r d3d44968969c tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp
--- a/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp  Thu Apr 28 07:08:38 2022 +0000
+++ b/tests/usr.bin/xlint/lint1/gcc_attribute_stmt.exp  Thu Apr 28 07:10:39 2022 +0000
@@ -1,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]



Home | Main Index | Thread Index | Old Index