diff options
author | Mark Mitchell <mark@codesourcery.com> | 2002-12-01 04:55:20 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2002-12-01 04:55:20 +0000 |
commit | 328de7c2f1018e5553f48760aa0b89bbc28d4c8b (patch) | |
tree | b245d8c933469c93a0bd802e68f291b65025b67f /gcc/cp/decl.c | |
parent | f6318a2baf8e87c2fd7f02308b3c2d05569684a2 (diff) | |
download | gcc-328de7c2f1018e5553f48760aa0b89bbc28d4c8b.zip gcc-328de7c2f1018e5553f48760aa0b89bbc28d4c8b.tar.gz gcc-328de7c2f1018e5553f48760aa0b89bbc28d4c8b.tar.bz2 |
re PR c++/8227 (g++ 3.3: ctors not called in static array initialization)
PR c++/8227
* decl.c (layout_var_decl): Deal gracefully with erroneous types.
(check_initializer): Validate the type of the initialized
variable, even if the initializer is absent.
* typeck.c (cp_type_quals): Deal gracefully with erroneous types.
PR c++/8227
* g++.dg/template/ctor2.C: New test.
From-SVN: r59672
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r-- | gcc/cp/decl.c | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5a30e5b..dbb96eb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7631,6 +7631,7 @@ layout_var_decl (decl) if (!DECL_EXTERNAL (decl)) complete_type (type); if (!DECL_SIZE (decl) + && TREE_TYPE (decl) != error_mark_node && (COMPLETE_TYPE_P (type) || (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) @@ -7974,33 +7975,30 @@ check_initializer (tree decl, tree init, int flags) the static initialization -- if any -- of DECL. */ DECL_INITIAL (decl) = NULL_TREE; - /* Check the initializer. */ - if (init) - { - /* Things that are going to be initialized need to have complete - type. */ - TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl)); + /* Things that are going to be initialized need to have complete + type. */ + TREE_TYPE (decl) = type = complete_type (TREE_TYPE (decl)); - if (type == error_mark_node) - /* We will have already complained. */ - init = NULL_TREE; - else if (COMPLETE_TYPE_P (type) && !TREE_CONSTANT (TYPE_SIZE (type))) - { - error ("variable-sized object `%D' may not be initialized", decl); - init = NULL_TREE; - } - else if (TREE_CODE (type) == ARRAY_TYPE - && !COMPLETE_TYPE_P (complete_type (TREE_TYPE (type)))) - { - error ("elements of array `%#D' have incomplete type", decl); - init = NULL_TREE; - } - else if (TREE_CODE (type) != ARRAY_TYPE && !COMPLETE_TYPE_P (type)) - { - error ("`%D' has incomplete type", decl); - TREE_TYPE (decl) = error_mark_node; - init = NULL_TREE; - } + if (type == error_mark_node) + /* We will have already complained. */ + init = NULL_TREE; + else if (init && COMPLETE_TYPE_P (type) + && !TREE_CONSTANT (TYPE_SIZE (type))) + { + error ("variable-sized object `%D' may not be initialized", decl); + init = NULL_TREE; + } + else if (TREE_CODE (type) == ARRAY_TYPE + && !COMPLETE_TYPE_P (complete_type (TREE_TYPE (type)))) + { + error ("elements of array `%#D' have incomplete type", decl); + init = NULL_TREE; + } + else if (TREE_CODE (type) != ARRAY_TYPE && !COMPLETE_TYPE_P (type)) + { + error ("`%D' has incomplete type", decl); + TREE_TYPE (decl) = error_mark_node; + init = NULL_TREE; } if (TREE_CODE (decl) == CONST_DECL) |