From 00de56c7d0e654b52c23e789dbe3cc32d361a527 Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 4 Jan 2001 21:56:00 -0800 Subject: [PATCH] 20000926-1.c: Update expected warnings. * 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 | 7 +++++++ gcc/testsuite/gcc.dg/20000926-1.c | 3 +-- gcc/testsuite/gcc.dg/array-2.c | 11 +++++++---- gcc/testsuite/gcc.dg/array-4.c | 15 ++++++++++++--- gcc/testsuite/gcc.dg/c99-flex-array-1.c | 8 ++++++++ 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/c99-flex-array-1.c 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 + + * 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 * 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 */ /* { 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[]; }; -- 2.30.2