summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-01-05 05:56:00 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2001-01-05 05:56:00 +0000
commita707dc90e7f242dab97dee41aed6e2d8470c0c00 (patch)
treeb4606c69a6e503b36bcef04bc2f8a017f8bd95f6 /gcc
parentc85601868d9ef12d39a8dbd8d57735af592a7293 (diff)
downloadgcc-a707dc90e7f242dab97dee41aed6e2d8470c0c00.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@38704 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.dg/20000926-1.c3
-rw-r--r--gcc/testsuite/gcc.dg/array-2.c11
-rw-r--r--gcc/testsuite/gcc.dg/array-4.c15
-rw-r--r--gcc/testsuite/gcc.dg/c99-flex-array-1.c8
5 files changed, 35 insertions, 9 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9661fc91515..59891ece4ec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/20000926-1.c b/gcc/testsuite/gcc.dg/20000926-1.c
index afaed989c21..bce1bb6626a 100644
--- a/gcc/testsuite/gcc.dg/20000926-1.c
+++ b/gcc/testsuite/gcc.dg/20000926-1.c
@@ -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)" "" } */
};
diff --git a/gcc/testsuite/gcc.dg/array-2.c b/gcc/testsuite/gcc.dg/array-2.c
index aa6f0c67397..dbf1733697d 100644
--- a/gcc/testsuite/gcc.dg/array-2.c
+++ b/gcc/testsuite/gcc.dg/array-2.c
@@ -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" } */
diff --git a/gcc/testsuite/gcc.dg/array-4.c b/gcc/testsuite/gcc.dg/array-4.c
index 9396dec3aa7..52ad92143a5 100644
--- a/gcc/testsuite/gcc.dg/array-4.c
+++ b/gcc/testsuite/gcc.dg/array-4.c
@@ -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
index 00000000000..b14397ad295
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-flex-array-1.c
@@ -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[]; };