summaryrefslogtreecommitdiff
path: root/gcc/cp/init.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-18 08:36:11 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2006-02-18 08:36:11 +0000
commitd91303a6d34c6e7d6e3eef52e8e486dfc7cac7d3 (patch)
treec096019ad738deb34504520ca833df4491508a99 /gcc/cp/init.c
parent819aeb26f6dcc0f1759eed90116a5f9e9e0e480d (diff)
downloadgcc-d91303a6d34c6e7d6e3eef52e8e486dfc7cac7d3.tar.gz
PR c++/26266
* cp-tree.h (cp_finish_decl): Adjust declaration. (grokbitfield): Likewise. (finish_static_data_member_decl): Likewise. * init.c (constant_value_1): Ensure processing_template_decl when folding non-dependent initializers for static data members of dependent types. Return error_mark_node for erroneous initailizers. * class.c (get_vtable_decl): Use finish_decl, not cp_finish_decl. * decl.c (cp_make_fname_decl): Adjust call to cp_finish_decl. (cp_finish_decl): Add init_const_expr_p parameter. Set DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here. (finish_decl): Adjust call to cp_finish_decl. (compute_array_index_type): Robustify. (start_method): Use finish_decl, not cp_finish_decl. * rtti.c (emit_tinfo_decl): Likewise. * except.c (initialize_handler_parm): Adjust call to cp_finish_decl. (expand_start_catch_block): Likewise. * cvt.c (build_up_reference): Adjust call to cp_finish_decl. * pt.c (instantiate_class_template): Adjust call to finish_static_data_member_decl. (tsubst_expr): Use finish_decl, not cp_finish_decl. (instantiate_decl): Adjust call to cp_finish_decl. * name-lookup.c (pushdecl_top_level_1): Use finish_decl, not cp_finish_decl. * decl2.c (finish_static_data_member_decl): Add init_const_expr_p parameter. (grokfield): Likewise. * parser.c (cp_parser_condition): Check for constant initializers. (cp_parser_init_declarator): Adjust calls to grokfield and cp_finish_decl. Don't set DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P here. (cp_parser_member_declaration): Likewise. (cp_parser_objc_class_ivars): Likewise. PR c++/26266 * g++.dg/template/static22.C: New test. * g++.dg/template/static23.C: New test. * g++.dg/template/static24.C: New test. * g++.dg/template/non-dependent13.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111229 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r--gcc/cp/init.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 0ef0c1ada73..6a7e625a00f 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -1484,7 +1484,7 @@ constant_value_1 (tree decl, bool integral_p)
tree init;
/* Static data members in template classes may have
non-dependent initializers. References to such non-static
- data members are no value-dependent, so we must retrieve the
+ data members are not value-dependent, so we must retrieve the
initializer here. The DECL_INITIAL will have the right type,
but will not have been folded because that would prevent us
from performing all appropriate semantic checks at
@@ -1493,7 +1493,11 @@ constant_value_1 (tree decl, bool integral_p)
&& CLASSTYPE_TEMPLATE_INFO (DECL_CONTEXT (decl))
&& uses_template_parms (CLASSTYPE_TI_ARGS
(DECL_CONTEXT (decl))))
- init = fold_non_dependent_expr (DECL_INITIAL (decl));
+ {
+ ++processing_template_decl;
+ init = fold_non_dependent_expr (DECL_INITIAL (decl));
+ --processing_template_decl;
+ }
else
{
/* If DECL is a static data member in a template
@@ -1503,7 +1507,9 @@ constant_value_1 (tree decl, bool integral_p)
mark_used (decl);
init = DECL_INITIAL (decl);
}
- if (!init || init == error_mark_node
+ if (init == error_mark_node)
+ return error_mark_node;
+ if (!init
|| !TREE_TYPE (init)
|| (integral_p
? !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (init))