Module Name: src
Committed By: rillig
Date: Tue Dec 28 22:54:08 UTC 2021
Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_init.c d_c99_init.exp
Log Message:
tests/lint: extend documentation for omitted braces in initializer
To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.28 -r1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.exp
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/d_c99_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.38 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.39
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.38 Wed Dec 22 14:49:11 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c Tue Dec 28 22:54:08 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: d_c99_init.c,v 1.38 2021/12/22 14:49:11 rillig Exp $ */
+/* $NetBSD: d_c99_init.c,v 1.39 2021/12/28 22:54:08 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@@ -81,7 +81,7 @@ int array_with_fixed_size[3] = {
444, /* expect: too many array initializers */
};
-// See initialization_set_set_of_unknown_array.
+// See update_type_of_array_of_unknown_size.
int array_of_unknown_size[] = {
111,
222,
@@ -150,8 +150,11 @@ int array_with_designator[] = {
* C99 6.7.8p11 says that the initializer of a scalar can be "optionally
* enclosed in braces". It does not explicitly set an upper limit on the
* number of braces. It also doesn't restrict the term "initializer" to only
- * mean the "outermost initializer". Both GCC 10 and Clang 8 already warn
- * about this, so there is no extra work for lint to do.
+ * mean the "outermost initializer". 6.7.8p13 defines that a brace for a
+ * structure or union always means to descend into the type. Both GCC 10 and
+ * Clang 8 already warn about these extra braces, nevertheless there is
+ * real-life code (the Postfix MTA) that exploits this corner case of the
+ * standard.
*/
struct point scalar_with_several_braces = {
{{{3}}},
Index: src/tests/usr.bin/xlint/lint1/d_c99_init.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.28 src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.29
--- src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.28 Wed Dec 22 00:45:53 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.exp Tue Dec 28 22:54:08 2021
@@ -3,27 +3,27 @@ d_c99_init.c(64): error: cannot initiali
d_c99_init.c(81): error: too many array initializers, expected 3 [173]
d_c99_init.c(139): error: too many struct/union initializers [172]
d_c99_init.c(145): error: syntax error 'designator '.member' is only for struct/union' [249]
-d_c99_init.c(218): error: array subscript cannot be > 2: 3 [168]
-d_c99_init.c(220): error: array subscript cannot be > 4: 5 [168]
-d_c99_init.c(222): error: array subscript cannot be > 1: 2 [168]
-d_c99_init.c(231): error: too many struct/union initializers [172]
-d_c99_init.c(237): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
-d_c99_init.c(331): error: negative array dimension (-8) [20]
-d_c99_init.c(333): error: negative array dimension (-12) [20]
-d_c99_init.c(386): error: duplicate case in switch: 0 [199]
-d_c99_init.c(394): error: negative array dimension (-12) [20]
-d_c99_init.c(398): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(405): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(412): error: type 'struct point' does not have member 'r' [101]
-d_c99_init.c(421): error: type 'union value' does not have member 'unknown_value' [101]
-d_c99_init.c(427): error: type 'union value' does not have member 'unknown_value' [101]
-d_c99_init.c(431): error: syntax error 'designator '[...]' is only for arrays' [249]
-d_c99_init.c(436): error: type 'struct point' does not have member 'member' [101]
-d_c99_init.c(441): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(448): warning: structure has no named members [65]
-d_c99_init.c(448): error: cannot initialize struct/union with no named member [179]
-d_c99_init.c(456): warning: union has no named members [65]
-d_c99_init.c(456): error: cannot initialize struct/union with no named member [179]
-d_c99_init.c(461): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(465): error: syntax error 'scalar type cannot use designator' [249]
-d_c99_init.c(469): error: syntax error 'designator '[...]' is only for arrays' [249]
+d_c99_init.c(221): error: array subscript cannot be > 2: 3 [168]
+d_c99_init.c(223): error: array subscript cannot be > 4: 5 [168]
+d_c99_init.c(225): error: array subscript cannot be > 1: 2 [168]
+d_c99_init.c(234): error: too many struct/union initializers [172]
+d_c99_init.c(240): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
+d_c99_init.c(334): error: negative array dimension (-8) [20]
+d_c99_init.c(336): error: negative array dimension (-12) [20]
+d_c99_init.c(389): error: duplicate case in switch: 0 [199]
+d_c99_init.c(397): error: negative array dimension (-12) [20]
+d_c99_init.c(401): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(408): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(415): error: type 'struct point' does not have member 'r' [101]
+d_c99_init.c(424): error: type 'union value' does not have member 'unknown_value' [101]
+d_c99_init.c(430): error: type 'union value' does not have member 'unknown_value' [101]
+d_c99_init.c(434): error: syntax error 'designator '[...]' is only for arrays' [249]
+d_c99_init.c(439): error: type 'struct point' does not have member 'member' [101]
+d_c99_init.c(444): error: syntax error 'scalar type cannot use designator' [249]
+d_c99_init.c(451): warning: structure has no named members [65]
+d_c99_init.c(451): error: cannot initialize struct/union with no named member [179]
+d_c99_init.c(459): warning: union has no named members [65]
+d_c99_init.c(459): error: cannot initialize struct/union with no named member [179]
+d_c99_init.c(464): error: syntax error 'scalar type cannot use designator' [249]
+d_c99_init.c(468): error: syntax error 'scalar type cannot use designator' [249]
+d_c99_init.c(472): error: syntax error 'designator '[...]' is only for arrays' [249]