From: steven Date: Tue, 1 Feb 2005 00:09:40 +0000 (+0000) Subject: gcc/ X-Git-Url: http://git.sourceforge.jp/view?p=pf3gnuchains%2Fgcc-fork.git;a=commitdiff_plain;h=b765c734625d155bc58a4bf8fe51a14f5f9e139e gcc/ 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. testsuite/ 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94505 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e58b0ab647b..7275decf14d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2005-01-31 Steven Bosscher + + 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 * cse.c (delete_trivially_dead_insn): Don't iterate. diff --git a/gcc/c-decl.c b/gcc/c-decl.c index efb17e89f82..ad76f235de9 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 fed17f24845..54f9714f514 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 cc1f201465d..258e232e888 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2005-01-31 Steven Bosscher + + 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 * g++.dg/opt/pr19650.C: New test. @@ -378,7 +390,7 @@ * gfortran.dg/write_to_null.f90: New test. 2005-01-14 Andrew Pinski - John David Anglin + John David Anglin PR other/19328 * gcc.dg/attr-alias-2.c: dg-require-alias takes an @@ -617,7 +629,7 @@ 2005-01-06 Mark Mitchell - PR c++/19244 + PR c++/19244 * g++.dg/parser/ctor2.C: New test. 2004-01-06 Kriang Lerdsuwanakij @@ -752,7 +764,7 @@ 2004-12-30 Alexander Malmberg Ziemowit Laski - PR objc/18971 + PR objc/18971 * objc.dg/encode-5.m: New test. 2004-12-29 Richard Henderson @@ -1100,7 +1112,7 @@ * cpp/inc/pragma-once-1a.h: Likewise. 2004-12-15 Bud Davis - Steven G. Kargl + Steven G. Kargl PR fortran/17597 * gfortran.dg/list_read_3.f90: New test. @@ -1525,7 +1537,7 @@ 2004-11-30 Loren James Rittle - * 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 @@ -1651,7 +1663,7 @@ 2004-11-28 Bud Davis - * gfortran.dg/direct_io_2.f90: New test. + * gfortran.dg/direct_io_2.f90: New test. 2004-11-28 Hans-Peter Nilsson @@ -1900,7 +1912,7 @@ * gcc.dg/vect/vect.exp (sparc*-*-*): Fix a couple of nits. 2004-11-19 Mark Mitchell - Joseph Myers + Joseph Myers * 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 - Mark Mitchell + Mark Mitchell * testsuite/gcc.dg/pragma-init-fini-2.c: New test. 2004-11-17 Janis Johnson - Aldy Hernandez + Aldy Hernandez * 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 - Andrew Pinski + Andrew Pinski PR tree-opt/18425 * gcc.dg/vect/pr18425.c: New test. @@ -2473,7 +2485,7 @@ 2004-11-10 Fariborz Jahanian - * 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 @@ -3137,7 +3149,7 @@ 2004-10-14 Andrew Pinski 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 diff --git a/gcc/testsuite/gcc.c-torture/compile/20011130-1.c b/gcc/testsuite/gcc.c-torture/compile/20011130-1.c index 82ff042cee6..55d4af482f2 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 fe1e7b49a58..7bf21bd4685 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 b32d4ea03d6..9e70b26821a 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 94df14a9ed9..ef5c3cbca43 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 09916be7989..b0699023a77 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 2d8bef3cb01..782251fa30a 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 be17e7ca4b3..c2a04f84c23 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 } */