Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src tests/lint: test syntax error in initialization using design...
details: https://anonhg.NetBSD.org/src/rev/518e694fb6bb
branches: trunk
changeset: 1021835:518e694fb6bb
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Jun 20 18:09:48 2021 +0000
description:
tests/lint: test syntax error in initialization using designator
This test prepares the upcoming refactoring of the grammar.
diffstat:
distrib/sets/lists/tests/mi | 4 ++-
tests/usr.bin/xlint/lint1/Makefile | 4 ++-
tests/usr.bin/xlint/lint1/c99_init_designator.c | 28 +++++++++++++++++++++++
tests/usr.bin/xlint/lint1/c99_init_designator.exp | 1 +
tests/usr.bin/xlint/lint1/t_integration.sh | 3 +-
5 files changed, 37 insertions(+), 3 deletions(-)
diffs (90 lines):
diff -r b944fb85dbf8 -r 518e694fb6bb distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Sun Jun 20 12:29:58 2021 +0000
+++ b/distrib/sets/lists/tests/mi Sun Jun 20 18:09:48 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1062 2021/06/19 20:25:57 rillig Exp $
+# $NetBSD: mi,v 1.1063 2021/06/20 18:09:48 rillig Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -6105,6 +6105,8 @@
./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/c99_init_designator.c tests-usr.bin-tests compattestfile,atf
+./usr/tests/usr.bin/xlint/lint1/c99_init_designator.exp tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_alignof.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_bltinoffsetof.c tests-usr.bin-tests compattestfile,atf
./usr/tests/usr.bin/xlint/lint1/d_c99_anon_struct.c tests-usr.bin-tests compattestfile,atf
diff -r b944fb85dbf8 -r 518e694fb6bb tests/usr.bin/xlint/lint1/Makefile
--- a/tests/usr.bin/xlint/lint1/Makefile Sun Jun 20 12:29:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/Makefile Sun Jun 20 18:09:48 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.64 2021/06/19 20:25:58 rillig Exp $
+# $NetBSD: Makefile,v 1.65 2021/06/20 18:09:48 rillig Exp $
NOMAN= # defined
MAX_MESSAGE= 344 # see lint1/err.c
@@ -10,6 +10,8 @@
TESTS_SH= t_integration
FILESDIR= ${TESTSDIR}
+FILES+= c99_init_designator.c
+FILES+= c99_init_designator.exp
FILES+= d_alignof.c
FILES+= d_bltinoffsetof.c
FILES+= d_c99_bool.c
diff -r b944fb85dbf8 -r 518e694fb6bb tests/usr.bin/xlint/lint1/c99_init_designator.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_init_designator.c Sun Jun 20 18:09:48 2021 +0000
@@ -0,0 +1,28 @@
+/* $NetBSD: c99_init_designator.c,v 1.1 2021/06/20 18:09:48 rillig Exp $ */
+# 3 "c99_init_designator.c"
+
+/*
+ * Test initialization of structs or unions using designators.
+ *
+ * See init.c, 'struct designator' and 'struct designation'.
+ *
+ * C99 6.7.8p6, 6.7.8p7
+ */
+
+struct point {
+ int x;
+ int y;
+};
+
+/*
+ * Before cgram.y 1.230 from 2021-06-20, the grammar allowed either of the
+ * operators '.' or '->' to be used for the designators and had extra code
+ * to ensure that only '.' was actually used.
+ */
+struct point origin = {
+ .x = 0,
+ ->y = 0, /* expect: syntax error '->' */
+};
+
+/* Ensure that the parser can recover from the parse error. */
+struct point pythagoras = { 3, 4 };
diff -r b944fb85dbf8 -r 518e694fb6bb tests/usr.bin/xlint/lint1/c99_init_designator.exp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/usr.bin/xlint/lint1/c99_init_designator.exp Sun Jun 20 18:09:48 2021 +0000
@@ -0,0 +1,1 @@
+c99_init_designator.c(24): error: syntax error '->' [249]
diff -r b944fb85dbf8 -r 518e694fb6bb tests/usr.bin/xlint/lint1/t_integration.sh
--- a/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 20 12:29:58 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/t_integration.sh Sun Jun 20 18:09:48 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_integration.sh,v 1.56 2021/06/19 20:25:58 rillig Exp $
+# $NetBSD: t_integration.sh,v 1.57 2021/06/20 18:09:48 rillig Exp $
#
# Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -99,6 +99,7 @@
test_case all_messages
+test_case c99_init_designator
test_case d_alignof
test_case d_bltinoffsetof
test_case d_c99_anon_struct
Home |
Main Index |
Thread Index |
Old Index