Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src tests/lint: merge tests for initialization



details:   https://anonhg.NetBSD.org/src/rev/21d01510bedc
branches:  trunk
changeset: 373361:21d01510bedc
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Feb 05 13:01:28 2023 +0000

description:
tests/lint: merge tests for initialization

diffstat:

 distrib/sets/lists/tests/mi                      |   6 ++--
 tests/usr.bin/xlint/lint1/d_c99_init.c           |  32 +++++++++++++++++++++++-
 tests/usr.bin/xlint/lint1/d_c99_recursive_init.c |  28 ---------------------
 tests/usr.bin/xlint/lint1/d_nolimit_init.c       |  10 -------
 4 files changed, 34 insertions(+), 42 deletions(-)

diffs (130 lines):

diff -r e46f4e3e9f95 -r 21d01510bedc distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi       Sun Feb 05 12:36:56 2023 +0000
+++ b/distrib/sets/lists/tests/mi       Sun Feb 05 13:01:28 2023 +0000
@@ -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
diff -r e46f4e3e9f95 -r 21d01510bedc tests/usr.bin/xlint/lint1/d_c99_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_init.c    Sun Feb 05 12:36:56 2023 +0000
+++ b/tests/usr.bin/xlint/lint1/d_c99_init.c    Sun Feb 05 13:01:28 2023 +0000
@@ -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 @@
        .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 @@
        "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 @@
        (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] */
diff -r e46f4e3e9f95 -r 21d01510bedc tests/usr.bin/xlint/lint1/d_c99_recursive_init.c
--- a/tests/usr.bin/xlint/lint1/d_c99_recursive_init.c  Sun Feb 05 12:36:56 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*     $NetBSD: d_c99_recursive_init.c,v 1.5 2021/02/20 22:31:20 rillig Exp $  */
-# 3 "d_c99_recursive_init.c"
-
-/* C99 recursive struct/union initialization */
-struct top {
-       int i;
-       char c;
-       union onion {
-               short us;
-               char uc;
-       } u;
-       char *s;
-} c[] = {
-       {
-               .s = "foo",
-               .c = 'b',
-               .u = {
-                       .uc = 'c'
-               }
-       },
-       {
-               .i = 1,
-               .c = 'a',
-               .u = {
-                       .us = 2
-               }
-       },
-};
diff -r e46f4e3e9f95 -r 21d01510bedc tests/usr.bin/xlint/lint1/d_nolimit_init.c
--- a/tests/usr.bin/xlint/lint1/d_nolimit_init.c        Sun Feb 05 12:36:56 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-/*     $NetBSD: d_nolimit_init.c,v 1.3 2021/03/27 13:59:18 rillig Exp $        */
-# 3 "d_nolimit_init.c"
-
-/*
- * no limit initializers, or as C99 calls it, initialization of an array of
- * unknown size
- */
-char weekday_names[][4] = {
-       "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
-};



Home | Main Index | Thread Index | Old Index