tests/lint: test syntax error in initialization using designator

This test prepares the upcoming refactoring of the grammar.
This commit is contained in:
rillig 2021-06-20 18:09:48 +00:00
parent fc9d104b4a
commit 513d7d3b4c
5 changed files with 37 additions and 3 deletions

View File

@ -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

View File

@ -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 @@ TESTSDIR= ${TESTSBASE}/usr.bin/xlint/lint1
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

View File

@ -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 };

View File

@ -0,0 +1 @@
c99_init_designator.c(24): error: syntax error '->' [249]

View File

@ -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()
test_case all_messages
test_case c99_init_designator
test_case d_alignof
test_case d_bltinoffsetof
test_case d_c99_anon_struct