diff options
author | Steven Bosscher <steven@gcc.gnu.org> | 2005-02-01 00:09:40 +0000 |
---|---|---|
committer | Steven Bosscher <steven@gcc.gnu.org> | 2005-02-01 00:09:40 +0000 |
commit | b4519d39bc85072ea1ec7b4ad254481d387a695c (patch) | |
tree | 5108a646eac36fa7b89c3f975f94db1d1aa39c65 /gcc/c-decl.c | |
parent | 286972677eedc731d85a7758a86023b9ebdc2b08 (diff) | |
download | gcc-b4519d39bc85072ea1ec7b4ad254481d387a695c.zip gcc-b4519d39bc85072ea1ec7b4ad254481d387a695c.tar.gz gcc-b4519d39bc85072ea1ec7b4ad254481d387a695c.tar.bz2 |
re PR c/19333 (C front end accepts arrays of incomplete types)
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.
From-SVN: r94505
Diffstat (limited to 'gcc/c-decl.c')
-rw-r--r-- | gcc/c-decl.c | 18 |
1 files changed, 8 insertions, 10 deletions
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; |