Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: test declarators with attributes



details:   https://anonhg.NetBSD.org/src/rev/5c2abee0f253
branches:  trunk
changeset: 1022575:5c2abee0f253
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jul 25 17:27:07 2021 +0000

description:
tests/lint: test declarators with attributes

diffstat:

 distrib/sets/lists/tests/mi                         |   4 +-
 tests/usr.bin/xlint/lint1/Makefile                  |   4 +-
 tests/usr.bin/xlint/lint1/parse_init_declarator.c   |  34 +++++++++++++++++++++
 tests/usr.bin/xlint/lint1/parse_init_declarator.exp |   3 +
 4 files changed, 43 insertions(+), 2 deletions(-)

diffs (81 lines):

diff -r 9927f14c5442 -r 5c2abee0f253 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Jul 25 16:57:23 2021 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Jul 25 17:27:07 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1094 2021/07/25 10:57:38 rillig Exp $
+# $NetBSD: mi,v 1.1095 2021/07/25 17:27:07 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6992,6 +6992,8 @@
 ./usr/tests/usr.bin/xlint/lint1/op_colon.exp                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.c                  tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/op_shl_lp64.exp                        tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_init_declarator.c                tests-usr.bin-tests     compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/parse_init_declarator.exp      tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/parse_stmt_error.c             tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/parse_stmt_error.exp           tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/parse_stmt_iter_error.c                tests-usr.bin-tests     compattestfile,atf
diff -r 9927f14c5442 -r 5c2abee0f253 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 25 16:57:23 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sun Jul 25 17:27:07 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.95 2021/07/25 10:57:38 rillig Exp $
+# $NetBSD: Makefile,v 1.96 2021/07/25 17:27:07 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   345             # see lint1/err.c
@@ -198,6 +198,8 @@
 FILES+=                op_colon.exp
 FILES+=                op_shl_lp64.c
 FILES+=                op_shl_lp64.exp
+FILES+=                parse_init_declarator.c
+FILES+=                parse_init_declarator.exp
 FILES+=                parse_stmt_error.c
 FILES+=                parse_stmt_error.exp
 FILES+=                parse_stmt_iter_error.c
diff -r 9927f14c5442 -r 5c2abee0f253 tests/usr.bin/xlint/lint1/parse_init_declarator.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_init_declarator.c Sun Jul 25 17:27:07 2021 +0000
@@ -0,0 +1,34 @@
+/*     $NetBSD: parse_init_declarator.c,v 1.1 2021/07/25 17:27:07 rillig Exp $ */
+# 3 "parse_init_declarator.c"
+
+/*
+ * Test parsing of init-declarator, which occurs as part of a top-level
+ * declaration.
+ *
+ * See also: GCC, c-parser.cpp, function c_parser_declaration_or_fndef.
+ */
+
+int global_var;
+
+int *init_declarator_without_initializer
+    __asm("") __attribute__((deprecated));
+/* expect-1: error: syntax error '__attribute__' [249] */
+/* FIXME */
+
+/* XXX: GCC does not accept this, neither should lint. */
+int *init_declarator_without_initializer_wrong_order
+    __attribute__((deprecated)) __asm("");
+
+int *init_declarator_with_initializer
+    __asm("") __attribute__((deprecated)) = &global_var;
+/* expect-1: error: syntax error '__attribute__' [249] */
+/* FIXME */
+
+/* XXX: GCC does not accept this, neither should lint. */
+int *init_declarator_with_initializer_wrong_order
+    __attribute__((deprecated)) __asm("") = &global_var;
+
+/* The attributes may only occur before the initializer, not after it. */
+int *init_declarator_with_initializer_attribute_too_late
+    __asm("") = &global_var __attribute__((deprecated));
+/* expect-1: error: syntax error '__attribute__' [249] */
diff -r 9927f14c5442 -r 5c2abee0f253 tests/usr.bin/xlint/lint1/parse_init_declarator.exp
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/parse_init_declarator.exp       Sun Jul 25 17:27:07 2021 +0000
@@ -0,0 +1,3 @@
+parse_init_declarator.c(14): error: syntax error '__attribute__' [249]
+parse_init_declarator.c(23): error: syntax error '__attribute__' [249]
+parse_init_declarator.c(33): error: syntax error '__attribute__' [249]



Home | Main Index | Thread Index | Old Index