Module Name: src
Committed By: rillig
Date: Sun Jul 25 18:34:44 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_attribute_enum.c
gcc_attribute_enum.exp
Log Message:
tests/lint: test __attribute__ with enum
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c \
src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.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_enum.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c:1.1 Tue Jul 6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.c Sun Jul 25 18:34:44 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gcc_attribute_enum.c,v 1.1 2021/07/06 17:33:07 rillig Exp $ */
+/* $NetBSD: gcc_attribute_enum.c,v 1.2 2021/07/25 18:34:44 rillig Exp $ */
# 3 "gcc_attribute_enum.c"
/*
@@ -7,16 +7,41 @@
* https://gcc.gnu.org/onlinedocs/gcc/Enumerator-Attributes.html
*/
-enum Planet {
- Mercury,
- Venus,
- Earth,
- Mars,
- Jupiter,
- Saturn,
- Uranus,
- Neptune,
- /* https://en.wikipedia.org/wiki/Pluto_(planet) */
- /*FIXME*//* expect+1: error: syntax error '__attribute__' [249] */
- Pluto __attribute__((__deprecated__ /* since August 2006 */))
+/*
+ * Attributes in enum-specifier.
+ *
+ * See GCC, c-parser.c, function c_parser_enum_specifier.
+ */
+
+/* expect+1: syntax error '__attribute__' [249] */
+enum __attribute__(()) tag;
+
+/* expect+2: syntax error '__attribute__' [249] */
+/* expect+1: syntax error '{' [249] */
+enum __attribute__(()) tag_with_declaration {
+ TAG_WITH_DECL
+} __attribute__(());
+/* expect-1: syntax error ';' [249] */
+
+/* expect+1: syntax error '{' [249] */
+enum __attribute__(()) {
+ ONLY_DECL
+} __attribute__(());
+/* expect-1: syntax error ';' [249] */
+/* expect-2: error: cannot recover from previous errors [224] */
+
+/*
+ * Attributes in enumerator.
+ *
+ * See GCC, c-parser.c, function c_parser_enum_specifier.
+ */
+
+enum {
+ NO_INIT_FIRST __attribute__(()),
+ NO_INIT__LAST __attribute__(())
+};
+
+enum {
+ INIT_FIRST __attribute__(()) = 1,
+ INIT__LAST __attribute__(()) = 2
};
Index: src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp
diff -u src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.1 src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.2
--- src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp:1.1 Tue Jul 6 17:33:07 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_attribute_enum.exp Sun Jul 25 18:34:44 2021
@@ -1 +1,7 @@
+gcc_attribute_enum.c(17): error: syntax error '__attribute__' [249]
gcc_attribute_enum.c(21): error: syntax error '__attribute__' [249]
+gcc_attribute_enum.c(21): error: syntax error '{' [249]
+gcc_attribute_enum.c(23): error: syntax error ';' [249]
+gcc_attribute_enum.c(27): error: syntax error '{' [249]
+gcc_attribute_enum.c(29): error: syntax error ';' [249]
+gcc_attribute_enum.c(29): error: cannot recover from previous errors [224]