Tue Mar 30 19:45:04 2021 UTC ()
tests/lint: test 'scalar type cannot use designator'


(rillig)
diff -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.c
diff -r1.22 -r1.23 src/tests/usr.bin/xlint/lint1/d_c99_init.exp

cvs diff -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.c (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 16:09:30 1.28
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c 2021/03/30 19:45:04 1.29
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: d_c99_init.c,v 1.28 2021/03/30 16:09:30 rillig Exp $ */ 1/* $NetBSD: d_c99_init.c,v 1.29 2021/03/30 19:45:04 rillig Exp $ */
2# 3 "d_c99_init.c" 2# 3 "d_c99_init.c"
3 3
4/* 4/*
5 * Test C99 initializers. 5 * Test C99 initializers.
6 * 6 *
7 * See C99 6.7.8 "Initialization". 7 * See C99 6.7.8 "Initialization".
8*/ 8*/
9 9
10 10
11void use(const void *); 11void use(const void *);
12 12
13typedef struct any { 13typedef struct any {
14 const void *value; 14 const void *value;
@@ -366,13 +366,22 @@ struct point designators_with_subscript  @@ -366,13 +366,22 @@ struct point designators_with_subscript
366}; 366};
367 367
368struct { 368struct {
369 int : 16; 369 int : 16;
370} struct_with_only_unnamed_members = { /* expect: has no named members */ 370} struct_with_only_unnamed_members = { /* expect: has no named members */
371 123, /* expect: too many struct/union initializers */ 371 123, /* expect: too many struct/union initializers */
372}; 372};
373 373
374union { 374union {
375 int : 16; 375 int : 16;
376} union_with_only_unnamed_members = { /* expect: has no named members */ 376} union_with_only_unnamed_members = { /* expect: has no named members */
377 123, /* expect: too many struct/union initializers */ 377 123, /* expect: too many struct/union initializers */
378}; 378};
 379
 380int designator_for_scalar = {
 381 .value = 3, /* expect: scalar type cannot use designator */
 382};
 383
 384struct point designator_for_scalar_in_struct = {
 385 { .x = 3 }, /* expect: scalar type cannot use designator */
 386 { [1] = 4 }, /* expect: scalar type cannot use designator */
 387};

cvs diff -r1.22 -r1.23 src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp (expand / switch to unified diff)

--- src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 16:09:30 1.22
+++ src/tests/usr.bin/xlint/lint1/Attic/d_c99_init.exp 2021/03/30 19:45:04 1.23
@@ -12,13 +12,16 @@ d_c99_init.c(240): warning: illegal comb @@ -12,13 +12,16 @@ d_c99_init.c(240): warning: illegal comb
12d_c99_init.c(279): error: cannot initialize 'struct <unnamed>' from 'int' [185] 12d_c99_init.c(279): error: cannot initialize 'struct <unnamed>' from 'int' [185]
13d_c99_init.c(321): error: duplicate case in switch: 0 [199] 13d_c99_init.c(321): error: duplicate case in switch: 0 [199]
14d_c99_init.c(330): error: type 'struct point' does not have member 'r' [101] 14d_c99_init.c(330): error: type 'struct point' does not have member 'r' [101]
15d_c99_init.c(337): error: type 'struct point' does not have member 'r' [101] 15d_c99_init.c(337): error: type 'struct point' does not have member 'r' [101]
16d_c99_init.c(344): error: type 'struct point' does not have member 'r' [101] 16d_c99_init.c(344): error: type 'struct point' does not have member 'r' [101]
17d_c99_init.c(353): error: type 'union value' does not have member 'unknown_value' [101] 17d_c99_init.c(353): error: type 'union value' does not have member 'unknown_value' [101]
18d_c99_init.c(359): error: type 'union value' does not have member 'unknown_value' [101] 18d_c99_init.c(359): error: type 'union value' does not have member 'unknown_value' [101]
19d_c99_init.c(363): error: syntax error 'designator '[...]' is only for arrays' [249] 19d_c99_init.c(363): error: syntax error 'designator '[...]' is only for arrays' [249]
20d_c99_init.c(364): error: type 'struct point' does not have member 'member' [101] 20d_c99_init.c(364): error: type 'struct point' does not have member 'member' [101]
21d_c99_init.c(370): warning: structure has no named members [65] 21d_c99_init.c(370): warning: structure has no named members [65]
22d_c99_init.c(371): error: too many struct/union initializers [172] 22d_c99_init.c(371): error: too many struct/union initializers [172]
23d_c99_init.c(376): warning: union has no named members [65] 23d_c99_init.c(376): warning: union has no named members [65]
24d_c99_init.c(377): error: too many struct/union initializers [172] 24d_c99_init.c(377): error: too many struct/union initializers [172]
 25d_c99_init.c(381): error: syntax error 'scalar type cannot use designator' [249]
 26d_c99_init.c(385): error: syntax error 'scalar type cannot use designator' [249]
 27d_c99_init.c(386): error: syntax error 'scalar type cannot use designator' [249]