aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/ChangeLog10
-rw-r--r--gcc/c-decl.c18
-rw-r--r--gcc/c-typeck.c6
-rw-r--r--gcc/testsuite/ChangeLog36
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/20011130-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/20030815-1.c8
-rw-r--r--gcc/testsuite/gcc.dg/array-7.c2
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/20000901-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/init-2.c2
-rw-r--r--gcc/testsuite/gcc.dg/noncompile/init-4.c3
-rw-r--r--gcc/testsuite/gcc.dg/pr18596-3.c2
11 files changed, 51 insertions, 40 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e58b0ab..7275dec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-31 Steven Bosscher <stevenb@suse.de>
+
+ PR c/19333
+ * c-decl.c (start_decl): Do not warn about arrays of elements with
+ an incomplete type here.
+ (grokdeclarator): Do it here by making a pedwarn an error.
+ * c-typeck.c (push_init_level): If there were previous errors with
+ the constructor type, do not warn about braces for initializers.
+ (process_init_element): Likewise for excess initializer elements.
+
2005-01-31 Kazu Hirata <kazu@cs.umass.edu>
* cse.c (delete_trivially_dead_insn): Don't iterate.
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index efb17e8..ad76f23 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -3039,11 +3039,6 @@ start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs,
error ("variable %qD has initializer but incomplete type", decl);
initialized = 0;
}
- else if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (decl))))
- {
- error ("elements of array %qD have incomplete type", decl);
- initialized = 0;
- }
else if (C_DECL_VARIABLE_SIZE (decl))
{
/* Although C99 is unclear about whether incomplete arrays
@@ -4148,11 +4143,14 @@ grokdeclarator (const struct c_declarator *declarator,
itype = build_range_type (sizetype, size_zero_node, NULL_TREE);
}
- /* If pedantic, complain about arrays of incomplete types. */
- if (pedantic && !COMPLETE_TYPE_P (type))
- pedwarn ("array type has incomplete element type");
-
- type = build_array_type (type, itype);
+ /* Complain about arrays of incomplete types. */
+ if (!COMPLETE_TYPE_P (type))
+ {
+ error ("array type has incomplete element type");
+ type = error_mark_node;
+ }
+ else
+ type = build_array_type (type, itype);
if (size_varies)
C_TYPE_VARIABLE_SIZE (type) = 1;
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index fed17f2..54f9714 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -4878,7 +4878,8 @@ push_init_level (int implicit)
}
else
{
- warning_init ("braces around scalar initializer");
+ if (constructor_type != error_mark_node)
+ warning_init ("braces around scalar initializer");
constructor_fields = constructor_type;
constructor_unfilled_fields = constructor_type;
}
@@ -6240,7 +6241,8 @@ process_init_element (struct c_expr value)
/* Handle the sole element allowed in a braced initializer
for a scalar variable. */
- else if (constructor_fields == 0)
+ else if (constructor_type != error_mark_node
+ && constructor_fields == 0)
{
pedwarn_init ("excess elements in scalar initializer");
break;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cc1f201..258e232 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+2005-01-31 Steven Bosscher <stevenb@suse.de>
+
+ PR c/19333
+ * testsuite/gcc.c-torture/compile/20011130-1.c: Reorder to make
+ the test case valid.
+ * testsuite/gcc.dg/20030815-1.c: Remove invalid tests.
+ * testsuite/gcc.dg/array-7.c: Adjust expected result.
+ * testsuite/gcc.dg/pr18596-3.c: Likewise.
+ * testsuite/gcc.dg/noncompile/20000901-1.c: Likewise.
+ * testsuite/gcc.dg/noncompile/init-2.c: Likewise.
+ * testsuite/gcc.dg/noncompile/init-4.c: Likewise.
+
2005-01-31 Dale Johannesen <dalej@apple.com>
* g++.dg/opt/pr19650.C: New test.
@@ -378,7 +390,7 @@
* gfortran.dg/write_to_null.f90: New test.
2005-01-14 Andrew Pinski <pinskia@physics.uc.edu>
- John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
+ John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
PR other/19328
* gcc.dg/attr-alias-2.c: dg-require-alias takes an
@@ -617,7 +629,7 @@
2005-01-06 Mark Mitchell <mark@codesourcery.com>
- PR c++/19244
+ PR c++/19244
* g++.dg/parser/ctor2.C: New test.
2004-01-06 Kriang Lerdsuwanakij <lerdsuwa@users.sourceforge.net>
@@ -752,7 +764,7 @@
2004-12-30 Alexander Malmberg <alexander@malmberg.org>
Ziemowit Laski <zlaski@apple.com>
- PR objc/18971
+ PR objc/18971
* objc.dg/encode-5.m: New test.
2004-12-29 Richard Henderson <rth@redhat.com>
@@ -1100,7 +1112,7 @@
* cpp/inc/pragma-once-1a.h: Likewise.
2004-12-15 Bud Davis <bdavis9659@comcast.net>
- Steven G. Kargl <kargls@comcast.net>
+ Steven G. Kargl <kargls@comcast.net>
PR fortran/17597
* gfortran.dg/list_read_3.f90: New test.
@@ -1525,7 +1537,7 @@
2004-11-30 Loren James Rittle <ljrittle@acm.org>
- * g++.old-deja/g++.eh/badalloc1.C (arena_size): Bump up to 262144
+ * g++.old-deja/g++.eh/badalloc1.C (arena_size): Bump up to 262144
to support new requirements on FreeBSD 5.
2004-11-30 Devang Patel <dpatel@apple.com>
@@ -1651,7 +1663,7 @@
2004-11-28 Bud Davis <bdavis9659@comcast.net>
- * gfortran.dg/direct_io_2.f90: New test.
+ * gfortran.dg/direct_io_2.f90: New test.
2004-11-28 Hans-Peter Nilsson <hp@bitrange.com>
@@ -1900,7 +1912,7 @@
* gcc.dg/vect/vect.exp (sparc*-*-*): Fix a couple of nits.
2004-11-19 Mark Mitchell <mark@codesourcery.com>
- Joseph Myers <joseph@codesourcery.com>
+ Joseph Myers <joseph@codesourcery.com>
* lib/target-supports.exp (check_visibility_available): Really
test the compiler.
@@ -1925,12 +1937,12 @@
* gcc.dg/ppc-mov-1.c: Ditto
2004-11-18 Daniel Jacobowitz <dan@codesourcery.com>
- Mark Mitchell <mark@codesourcery.com>
+ Mark Mitchell <mark@codesourcery.com>
* testsuite/gcc.dg/pragma-init-fini-2.c: New test.
2004-11-17 Janis Johnson <janis187@us.ibm.com>
- Aldy Hernandez <aldyh@redhat.com>
+ Aldy Hernandez <aldyh@redhat.com>
* lib/target-supports.exp (check_effective_target_vect_int): New
(check_effective_target_vect_float): New
@@ -2224,7 +2236,7 @@
* gcc.dg/vect/pr18400.c: New test.
2004-11-14 Dorit Naishlos <dorit@il.ibm.com>
- Andrew Pinski <pinskia@physics.uc.edu>
+ Andrew Pinski <pinskia@physics.uc.edu>
PR tree-opt/18425
* gcc.dg/vect/pr18425.c: New test.
@@ -2473,7 +2485,7 @@
2004-11-10 Fariborz Jahanian <fjahanian@apple.com>
- * gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c:
+ * gcc.c-torture/execute/ieee/unsafe-fp-assoc-1.c:
New test for PR tree-optimization/17892.
2004-11-09 Mark Mitchell <mark@codesourcery.com>
@@ -3137,7 +3149,7 @@
2004-10-14 Andrew Pinski <pinskia@physics.uc.edu>
PR middle-end/16567
- * gcc.c-torture/compile/nested-1.c: New test.
+ * gcc.c-torture/compile/nested-1.c: New test.
2004-10-14 Dorit Naishlos <dorit@il.ibm.com>
diff --git a/gcc/testsuite/gcc.c-torture/compile/20011130-1.c b/gcc/testsuite/gcc.c-torture/compile/20011130-1.c
index 82ff042..55d4af4 100644
--- a/gcc/testsuite/gcc.c-torture/compile/20011130-1.c
+++ b/gcc/testsuite/gcc.c-torture/compile/20011130-1.c
@@ -1,5 +1,5 @@
-extern struct S x[];
struct S { int i; };
+extern struct S x[];
char *bar (const struct S *);
void foo (void)
{
diff --git a/gcc/testsuite/gcc.dg/20030815-1.c b/gcc/testsuite/gcc.dg/20030815-1.c
index fe1e7b4..7bf21bd 100644
--- a/gcc/testsuite/gcc.dg/20030815-1.c
+++ b/gcc/testsuite/gcc.dg/20030815-1.c
@@ -4,10 +4,6 @@
/* { dg-do compile } */
/* { dg-options "" } */
-typedef struct a A[1];
-typedef struct b B[1];
-typedef struct c C[1];
-typedef struct d D[1];
typedef struct a E;
typedef struct b F;
typedef struct c G;
@@ -16,10 +12,6 @@ struct a { int a; };
struct c { int c; };
struct d { int d; };
struct b { int b; };
-int sa = sizeof (A);
-int sb = sizeof (B);
-int sc = sizeof (C);
-int sd = sizeof (D);
int se = sizeof (E);
int sf = sizeof (F);
int sg = sizeof (G);
diff --git a/gcc/testsuite/gcc.dg/array-7.c b/gcc/testsuite/gcc.dg/array-7.c
index b32d4ea..9e70b26 100644
--- a/gcc/testsuite/gcc.dg/array-7.c
+++ b/gcc/testsuite/gcc.dg/array-7.c
@@ -11,4 +11,4 @@ f (void)
struct foo { int a; int b; };
}
-struct foo array[5]; /* { dg-error "storage size" } */
+struct foo array[5]; /* { dg-error "array type has incomplete element type" } */
diff --git a/gcc/testsuite/gcc.dg/noncompile/20000901-1.c b/gcc/testsuite/gcc.dg/noncompile/20000901-1.c
index 94df14a..ef5c3cb 100644
--- a/gcc/testsuite/gcc.dg/noncompile/20000901-1.c
+++ b/gcc/testsuite/gcc.dg/noncompile/20000901-1.c
@@ -1 +1 @@
-struct foo bar[] = { {"baz"} }; /* { dg-error "have incomplete type|excess elements|near|assumed|storage size" } */
+struct foo bar[] = { {"baz"} }; /* { dg-error "array type has incomplete element type" } */
diff --git a/gcc/testsuite/gcc.dg/noncompile/init-2.c b/gcc/testsuite/gcc.dg/noncompile/init-2.c
index 09916be7..b069902 100644
--- a/gcc/testsuite/gcc.dg/noncompile/init-2.c
+++ b/gcc/testsuite/gcc.dg/noncompile/init-2.c
@@ -1 +1 @@
-int d[][] = { {1}, {2}, {3} }; /* { dg-error "incomplete type|storage size|one element" } */
+int d[][] = { {1}, {2}, {3} }; /* { dg-error "incomplete element type" } */
diff --git a/gcc/testsuite/gcc.dg/noncompile/init-4.c b/gcc/testsuite/gcc.dg/noncompile/init-4.c
index 2d8bef3..782251f 100644
--- a/gcc/testsuite/gcc.dg/noncompile/init-4.c
+++ b/gcc/testsuite/gcc.dg/noncompile/init-4.c
@@ -1,2 +1 @@
-struct a { char *b; } c[D] /* { dg-error "undeclared" } */
- = { { "" } } ; /* { dg-warning "braces around scalar initializer|near" } */
+struct a { char *b; } c[D]; /* { dg-error "undeclared" } */
diff --git a/gcc/testsuite/gcc.dg/pr18596-3.c b/gcc/testsuite/gcc.dg/pr18596-3.c
index be17e7c..c2a04f8 100644
--- a/gcc/testsuite/gcc.dg/pr18596-3.c
+++ b/gcc/testsuite/gcc.dg/pr18596-3.c
@@ -10,5 +10,3 @@ int foo ()
static int j () = /* { dg-error "invalid storage class" } */
{ 0, 0.0 };
}
-/* { dg-warning "excess elements" "" { target *-*-* } 11 } */
-/* { dg-warning "near initialization" "" { target *-*-* } 11 } */