20000926-1.c: Update expected warnings.
authorRichard Henderson <rth@redhat.com>
Fri, 5 Jan 2001 05:56:00 +0000 (21:56 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Fri, 5 Jan 2001 05:56:00 +0000 (21:56 -0800)
        * gcc.dg/20000926-1.c: Update expected warnings.
        * gcc.dg/array-2.c: Likewise.
        * gcc.dg/array-4.c: Also validate flexible array members.
        * gcc.dg/c99-flex-array-1.c: New.

From-SVN: r38704

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20000926-1.c
gcc/testsuite/gcc.dg/array-2.c
gcc/testsuite/gcc.dg/array-4.c
gcc/testsuite/gcc.dg/c99-flex-array-1.c [new file with mode: 0644]

index 9661fc915151e77626f9fade44f0971c298db7d2..59891ece4ec62ba075dd437e4098fdec84da7c03 100644 (file)
@@ -1,3 +1,10 @@
+2001-01-04  Richard Henderson  <rth@redhat.com>
+
+       * gcc.dg/20000926-1.c: Update expected warnings.
+       * gcc.dg/array-2.c: Likewise.
+       * gcc.dg/array-4.c: Also validate flexible array members.
+       * gcc.dg/c99-flex-array-1.c: New.
+
 2001-01-04  Joseph S. Myers  <jsm28@cam.ac.uk>
 
        * gcc.c-torture/compile/20001222-1.x: Remove.
index afaed989c21f09cc4b2e7486bacdcfda4e1c6969..bce1bb6626a6a77e4f2e54d3252e57111d765690 100644 (file)
@@ -1,5 +1,4 @@
 /* Copyright (C) 2000  Free Software Foundation.
-
    by William Cohen  <wcohen@redhat.com>  */
 
 /* { dg-do compile } */
@@ -23,5 +22,5 @@ struct PLAYBOOK playbook  =
   "BookName",
   {
     { 1, "PName0" },
-  }
+  } /* { dg-warning "(deprecated initialization)|(near initialization)" "" } */
 };
index aa6f0c67397e440a0c4978c4d4bbf95e7b3a5575..dbf1733697d2cbfcd1e2587eef5dfa78dbce0952 100644 (file)
@@ -1,10 +1,13 @@
 /* { dg-do compile } */
-/* { dg-options "" } */
+/* { dg-options "-w" } */
 
 /* Verify that we can't do things to get ourselves in trouble
-   with GCC's zero-length array extension.  */
+   with GCC's initialized flexible array member extension.  */
 
-struct f { int w; int x[0]; };
+struct f { int w; int x[]; };
 struct g { struct f f; };
 struct g g1 = { { 0, { } } };
-struct g g2 = { { 0, { 1 } } }; /* { dg-error "(nested structure)|(near initialization)" "nested" } */
+struct g g2 = { { 0, { 1 } } }; /* { dg-error "(nested context)|(near initialization)" "nested" } */
+
+struct h { int x[0]; int y; };
+struct h h1 = { { 0 }, 1 }; /* { dg-error "(before end)|(near initialization)" "before end" } */
index 9396dec3aa7041c3bad6dd47a6b7c3e7f8487b36..52ad92143a55c761f7c956656adc40e3ddcb73d4 100644 (file)
@@ -1,13 +1,19 @@
 /* { dg-do run } */
 /* { dg-options "" } */
 
-/* Verify that GCC's extension to initialize a zero-length array
-   member works properly.  */
+/* Verify that GCC's initialized flexible array member extension
+   works properly.  */
 
 extern void abort(void);
 extern void exit(int);
 
-struct f { int w; int x[0]; } f = { 4, { 0, 1, 2, 3 } };
+struct f { int w; int x[]; };
+struct g { int w; int x[0]; };
+
+static struct f f = { 4, { 0, 1, 2, 3 } };
+static int junk1[] = { -1, -1, -1, -1 };
+static struct g g = { 4, { 0, 1, 2, 3 } }; /* { dg-warning "(deprecated initialization)|(near initialization)" "" } */
+static int junk2[] = { -1, -1, -1, -1 };
 
 int main()
 {
@@ -15,5 +21,8 @@ int main()
   for (i = 0; i < f.w; ++i)
     if (f.x[i] != i)
       abort ();
+  for (i = 0; i < g.w; ++i)
+    if (g.x[i] != i)
+      abort ();
   exit(0);
 }
diff --git a/gcc/testsuite/gcc.dg/c99-flex-array-1.c b/gcc/testsuite/gcc.dg/c99-flex-array-1.c
new file mode 100644 (file)
index 0000000..b14397a
--- /dev/null
@@ -0,0 +1,8 @@
+/* Test for invalid uses of flexible array members.  */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+struct s1 { int x[]; }; /* { dg-error "empty struct" "empty" } */
+struct s2 { int :1; int x[]; }; /* { dg-error "empty struct" "empty" } */
+struct s3 { int x[]; int y; }; /* { dg-error "not at end" "not at end" } */
+struct s4 { int x; int y[]; };