Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/usr.bin/xlint/lint1 tests/lint: extend documentation f...
details: https://anonhg.NetBSD.org/src/rev/324354ff7a8f
branches: trunk
changeset: 1029268:324354ff7a8f
user: rillig <rillig%NetBSD.org@localhost>
date: Tue Dec 28 22:54:08 2021 +0000
description:
tests/lint: extend documentation for omitted braces in initializer
diffstat:
tests/usr.bin/xlint/lint1/d_c99_init.c | 11 ++++--
tests/usr.bin/xlint/lint1/d_c99_init.exp | 48 ++++++++++++++++----------------
2 files changed, 31 insertions(+), 28 deletions(-)
diffs (87 lines):
diff -r 27c4e52215e5 -r 324354ff7a8f tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c Tue Dec 28 22:13:56 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c Tue Dec 28 22:54:08 2021 +0000
@@ -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 @@
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 @@
* 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}}},
diff -r 27c4e52215e5 -r 324354ff7a8f tests/usr.bin/xlint/lint1/d_c99_init.exp
--- a/tests/usr.bin/xlint/lint1/d_c99_init.exp Tue Dec 28 22:13:56 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.exp Tue Dec 28 22:54:08 2021 +0000
@@ -3,27 +3,27 @@
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]
Home |
Main Index |
Thread Index |
Old Index