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: add more tests for ini...



details:   https://anonhg.NetBSD.org/src/rev/93dbe53f93f7
branches:  trunk
changeset: 953758:93dbe53f93f7
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 20 08:59:46 2021 +0000

description:
tests/lint: add more tests for initialization, based on C99 6.7.8

diffstat:

 tests/usr.bin/xlint/lint1/d_c99_init.c |  35 +++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diffs (47 lines):

diff -r e11445a1cec1 -r 93dbe53f93f7 tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c    Sat Mar 20 08:54:27 2021 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Sat Mar 20 08:59:46 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: d_c99_init.c,v 1.11 2021/03/20 08:54:27 rillig Exp $   */
+/*     $NetBSD: d_c99_init.c,v 1.12 2021/03/20 08:59:46 rillig Exp $   */
 # 3 "d_c99_init.c"
 
 /*
@@ -144,4 +144,37 @@
        {{{{4}}}},
 };
 
+struct rectangle {
+       struct point top_left;
+       struct point bottom_right;
+};
+
+/* C99 6.7.8p18 */
+struct rectangle screen = {
+       .bottom_right = {
+               1920,
+               1080,
+       }
+};
+
+/*
+ * C99 6.7.8p22 says: At the _end_ of its initializer list, the array no
+ * longer has incomplete type.
+ */
+struct point points[] = {
+       {
+               /*
+                * At this point, the size of the object 'points' is not known
+                * yet since its type is still incomplete.  Lint could warn
+                * about this, but GCC and Clang already do.
+                *
+                * This test case demonstrates that in
+                * extend_if_array_of_unknown_size, setcomplete is called too
+                * early.
+                */
+               sizeof points,
+               4
+       }
+};
+
 // See d_struct_init_nested.c for a more complicated example.



Home | Main Index | Thread Index | Old Index