Module Name: src Committed By: rillig Date: Sun Feb 5 13:01:28 UTC 2023
Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/xlint/lint1: d_c99_init.c Removed Files: src/tests/usr.bin/xlint/lint1: d_c99_recursive_init.c d_nolimit_init.c Log Message: tests/lint: merge tests for initialization To generate a diff of this commit: cvs rdiff -u -r1.1251 -r1.1252 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.43 -r1.44 src/tests/usr.bin/xlint/lint1/d_c99_init.c cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c cvs rdiff -u -r1.3 -r0 src/tests/usr.bin/xlint/lint1/d_nolimit_init.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1251 src/distrib/sets/lists/tests/mi:1.1252 --- src/distrib/sets/lists/tests/mi:1.1251 Sun Feb 5 12:25:11 2023 +++ src/distrib/sets/lists/tests/mi Sun Feb 5 13:01:28 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1251 2023/02/05 12:25:11 rillig Exp $ +# $NetBSD: mi,v 1.1252 2023/02/05 13:01:28 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6453,7 +6453,7 @@ ./usr/tests/usr.bin/xlint/lint1/d_c99_init.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_init.exp tests-obsolete obsolete,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_nested_struct.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c tests-obsolete obsolete,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_struct_init.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_union_cast.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_c99_union_cast.exp tests-obsolete obsolete,atf @@ -6503,7 +6503,7 @@ ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_long_double_int.exp tests-obsolete obsolete,atf ./usr/tests/usr.bin/xlint/lint1/d_nested_structs.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/xlint/lint1/d_nolimit_init.c tests-obsolete obsolete,atf ./usr/tests/usr.bin/xlint/lint1/d_packed_structs.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_pr_22119.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/xlint/lint1/d_pr_22119.exp tests-obsolete obsolete,atf Index: src/tests/usr.bin/xlint/lint1/d_c99_init.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.43 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.44 --- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.43 Sun Feb 5 12:25:11 2023 +++ src/tests/usr.bin/xlint/lint1/d_c99_init.c Sun Feb 5 13:01:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_init.c,v 1.43 2023/02/05 12:25:11 rillig Exp $ */ +/* $NetBSD: d_c99_init.c,v 1.44 2023/02/05 13:01:28 rillig Exp $ */ # 3 "d_c99_init.c" /* @@ -144,6 +144,20 @@ struct point point_with_mixed_designator .x = 3, }; +/* + * 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, + /* expect+1: error: syntax error '->' [249] */ + ->y = 0, +}; + +/* Ensure that the parser can recover from the parse error. */ +struct point pythagoras = { 3, 4 }; + int array_with_designator[] = { 111, /* expect+1: error: syntax error 'designator '.member' is only for struct/union' [249] */ @@ -492,6 +506,11 @@ const char string_initialized_with_brace "initializer", }; +// An array of unknown size containing strings. +char weekday_names[][4] = { + "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" +}; + /* nested struct/union initialization */ struct outer { int i; @@ -532,3 +551,14 @@ struct offset_and_data offset_and_data = (unsigned long)&(((struct offset_and_data *)0)->data), 0, }; + +// The size of the array is determined by the maximum index, not by the last +// one mentioned. +int arr_11[] = { [10] = 10, [0] = 0 }; +typedef int ctassert_11[-(int)(sizeof(arr_11) / sizeof(arr_11[0]))]; +/* expect-1: error: negative array dimension (-11) [20] */ + +// Without an explicit subscript designator, the subscript counts up. +int arr_3[] = { [1] = 1, [0] = 0, 1, 2 }; +typedef int ctassert_3[-(int)(sizeof(arr_3) / sizeof(arr_3[0]))]; +/* expect-1: error: negative array dimension (-3) [20] */