Source-Changes-HG archive

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

[src/trunk]: src tests/lint: test _Atomic, added in C11



details:   https://anonhg.NetBSD.org/src/rev/266af144bc16
branches:  trunk
changeset: 373147:266af144bc16
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 21 11:57:03 2023 +0000

description:
tests/lint: test _Atomic, added in C11

diffstat:

 distrib/sets/lists/tests/mi            |   4 +++-
 tests/usr.bin/xlint/lint1/Makefile     |   4 +++-
 tests/usr.bin/xlint/lint1/c11_atomic.c |  27 +++++++++++++++++++++++++++
 tests/usr.bin/xlint/lint1/c99_atomic.c |  18 ++++++++++++++++++
 4 files changed, 51 insertions(+), 2 deletions(-)

diffs (95 lines):

diff -r b0eb3dfd4130 -r 266af144bc16 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sat Jan 21 11:29:30 2023 +0000
+++ b/distrib/sets/lists/tests/mi       Sat Jan 21 11:57:03 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1244 2023/01/19 23:26:14 rillig Exp $
+# $NetBSD: mi,v 1.1245 2023/01/21 11:57:03 rillig Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -6413,10 +6413,12 @@
 ./usr/tests/usr.bin/xlint/lint1                                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/Atffile                                tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/Kyuafile                       tests-usr.bin-tests     compattestfile,atf,kyua
+./usr/tests/usr.bin/xlint/lint1/c11_atomic.c                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.c       tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c11_generic_expression.exp     tests-obsolete          obsolete,atf
 ./usr/tests/usr.bin/xlint/lint1/c90.c                          tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c90.exp                                tests-obsolete          obsolete,atf
+./usr/tests/usr.bin/xlint/lint1/c99_atomic.c                   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.c   tests-usr.bin-tests     compattestfile,atf
 ./usr/tests/usr.bin/xlint/lint1/c99_bool_strict_suppressed.exp tests-obsolete          obsolete
 ./usr/tests/usr.bin/xlint/lint1/c99_init_array.c               tests-usr.bin-tests     compattestfile,atf
diff -r b0eb3dfd4130 -r 266af144bc16 tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile        Sat Jan 21 11:29:30 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile        Sat Jan 21 11:57:03 2023 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.131 2023/01/15 00:53:19 rillig Exp $
+# $NetBSD: Makefile,v 1.132 2023/01/21 11:57:03 rillig Exp $
 
 NOMAN=         # defined
 MAX_MESSAGE=   349             # see lint1/err.c
@@ -18,8 +18,10 @@
        @echo archsubdir=${ARCHSUBDIR} >${.TARGET}
 
 FILESDIR=      ${TESTSDIR}
+FILES+=                c11_atomic.c
 FILES+=                c11_generic_expression.c
 FILES+=                c90.c
+FILES+=                c99_atomic.c
 FILES+=                c99_bool_strict_suppressed.c
 FILES+=                c99_init_array.c
 FILES+=                c99_init_designator.c
diff -r b0eb3dfd4130 -r 266af144bc16 tests/usr.bin/xlint/lint1/c11_atomic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c11_atomic.c    Sat Jan 21 11:57:03 2023 +0000
@@ -0,0 +1,27 @@
+/*     $NetBSD: c11_atomic.c,v 1.1 2023/01/21 11:57:03 rillig Exp $    */
+# 3 "c11_atomic.c"
+
+/*
+ * The keyword '_Atomic' was added in C11.  This test ensures that in C11
+ * mode, '_Atomic' can be used as both type qualifier and type specifier.
+ *
+ * See also:
+ *     C11 6.7.3 Type qualifiers
+ *     C11 6.7.2.4 Atomic type specifiers
+ */
+
+/* lint1-extra-flags: -Ac11 */
+
+/* FIXME: The error messages are misleading. */
+
+/* C11 6.7.3 "Type qualifiers" */
+/* expect+2: error: old-style declaration; add 'int' [1] */
+/* expect+1: error: syntax error 'int' [249] */
+typedef _Atomic int atomic_int;
+
+typedef _Atomic struct {
+       int field;
+} atomic_struct;
+/* expect-1: error: illegal type combination [4] */
+
+/* TODO: C11 6.7.2.4 "Atomic type specifiers" */
diff -r b0eb3dfd4130 -r 266af144bc16 tests/usr.bin/xlint/lint1/c99_atomic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_atomic.c    Sat Jan 21 11:57:03 2023 +0000
@@ -0,0 +1,18 @@
+/*     $NetBSD: c99_atomic.c,v 1.1 2023/01/21 11:57:03 rillig Exp $    */
+# 3 "c99_atomic.c"
+
+/*
+ * The keyword '_Atomic' was added in C11.  This test ensures that in C99
+ * mode, the parser recognizes the keyword but flags it.
+ */
+
+/* FIXME: The error messages are misleading. */
+
+/* expect+2: error: old-style declaration; add 'int' [1] */
+/* expect+1: error: syntax error 'int' [249] */
+typedef _Atomic int atomic_int;
+
+typedef _Atomic struct {
+       int field;
+} atomic_struct;
+/* expect-1: error: illegal type combination [4] */



Home | Main Index | Thread Index | Old Index