diff options
| author | Mark Mitchell <mark@codesourcery.com> | 2005-08-29 14:08:50 +0000 |
|---|---|---|
| committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-08-29 14:08:50 +0000 |
| commit | b794e321c163674e83fa0b8f7a7aa1b4359c918c (patch) | |
| tree | a365e22cb324c02aefb465f5f8efd813b9e48964 /gcc/cp/init.c | |
| parent | 3a6ebcdceed08428c1d47a1f30119bbab87cbd8d (diff) | |
| download | gcc-b794e321c163674e83fa0b8f7a7aa1b4359c918c.zip gcc-b794e321c163674e83fa0b8f7a7aa1b4359c918c.tar.gz gcc-b794e321c163674e83fa0b8f7a7aa1b4359c918c.tar.bz2 | |
re PR c++/23099 (ICE in build_simple_base_path, at cp/class.c:460)
PR c++/23099
* cp-tree.h (saved_scope): Add skip_evaluation.
* decl.c (start_decl): Use DECL_INITIALIZED_IN_CLASS_P, not
DECL_INITIAL, to determine whether or not a static data member was
initialized in the class-specifier.
(cp_finish_decl): Add comment.
* init.c (integral_constant_value): Subtitute into the
initializers for static data members in templates.
* name-lookup.c (push_to_top_level): Save skip_evaluation.
(pop_from_top_level): Restore it.
* pt.c (instantiate_class_template): Do not substitute into the
intializers of static data members when instantiating a class.
(regenerate_decl_from_template): Simplify.
(instantiate_decl): Tidy. Substitute into the initializer for a
static data member even when the definition of the data member is
not available.
PR c++/23099
* g++.dg/init/member1.C: Make sure erroneous static data member
definitions are required.
* g++.dg/template/static13.C: New test.
* g++.dg/template/static14.C: Likewise.
From-SVN: r103604
Diffstat (limited to 'gcc/cp/init.c')
| -rw-r--r-- | gcc/cp/init.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 690e35f..8a8dc78 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1572,12 +1572,25 @@ integral_constant_value (tree decl) /* And so are variables with a 'const' type -- unless they are also 'volatile'. */ && CP_TYPE_CONST_NON_VOLATILE_P (TREE_TYPE (decl)) - && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))) - && DECL_INITIAL (decl) - && DECL_INITIAL (decl) != error_mark_node - && TREE_TYPE (DECL_INITIAL (decl)) - && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (DECL_INITIAL (decl)))) - decl = DECL_INITIAL (decl); + && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl)))) + { + tree init; + /* If DECL is a static data member in a template class, we must + instantiate it here. The initializer for the static data + member is not processed until needed; we need it now. */ + mark_used (decl); + init = DECL_INITIAL (decl); + /* If we are currently processing a template, the + initializer for a static data member may not be dependent, + but it is not folded until instantiation time. */ + if (init) + init = fold_non_dependent_expr (init); + if (!(init || init == error_mark_node) + || !TREE_TYPE (init) + || !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (init))) + break; + decl = init; + } return decl; } |
