diff options
author | Mark Mitchell <mark@codesourcery.com> | 2005-09-08 18:56:42 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2005-09-08 18:56:42 +0000 |
commit | 024f1251b584243372c0413105b2230769f3e682 (patch) | |
tree | 794733d783728df4d410d1633a0e1e80bb479f43 | |
parent | 0348d6fd857a367763b2e7c59449aa545b5c8c14 (diff) | |
download | gcc-024f1251b584243372c0413105b2230769f3e682.zip gcc-024f1251b584243372c0413105b2230769f3e682.tar.gz gcc-024f1251b584243372c0413105b2230769f3e682.tar.bz2 |
re PR c++/23691 (`mpl_::bool_<false>::value' is not a valid template argument for type `bool' because it is a non-constant expression)
PR c++/23691
* decl2.c (mark_used): Instantiate static data members initialized
by constants, even in a template.
PR c++/23691
* g++.dg/template/static16.C: New test.
From-SVN: r104041
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 30 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 |
3 files changed, 40 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 89a9656..795b2a1 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2005-09-08 Mark Mitchell <mark@codesourcery.com> + + PR c++/23691 + * decl2.c (mark_used): Instantiate static data members initialized + by constants, even in a template. + 2005-09-08 Andrew Pinski <pinskia@physics.uc.edu> PR obj-c++/16816 diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 87ef858..a6e82f0 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -3217,12 +3217,38 @@ check_default_args (tree x) } } +/* Mark DECL as "used" in the program. If DECL is a specialization or + implicitly declared class member, generate the actual definition. */ + void mark_used (tree decl) { + HOST_WIDE_INT saved_processing_template_decl = 0; + TREE_USED (decl) = 1; - if (processing_template_decl || skip_evaluation) + /* If we don't need a value, then we don't need to synthesize DECL. */ + if (skip_evaluation) return; + /* Normally, we can wait until instantiation-time to synthesize + DECL. However, if DECL is a static data member initialized with + a constant, we need the value right now because a reference to + such a data member is not value-dependent. */ + if (processing_template_decl) + { + if (TREE_CODE (decl) == VAR_DECL + && DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl) + && DECL_CLASS_SCOPE_P (decl) + && !dependent_type_p (DECL_CONTEXT (decl))) + { + /* Pretend that we are not in a template so that the + initializer for the static data member will be full + simplified. */ + saved_processing_template_decl = processing_template_decl; + processing_template_decl = 0; + } + else + return; + } if (TREE_CODE (decl) == FUNCTION_DECL && DECL_DECLARED_INLINE_P (decl) && !TREE_ASM_WRITTEN (decl)) @@ -3282,6 +3308,8 @@ mark_used (tree decl) need. */ instantiate_decl (decl, /*defer_ok=*/true, /*expl_inst_class_mem_p=*/false); + + processing_template_decl = saved_processing_template_decl; } #include "gt-cp-decl2.h" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 9690bb5..4fa4a7d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-09-08 Mark Mitchell <mark@codesourcery.com> + + PR c++/23691 + * g++.dg/template/static16.C: New test. + 2005-09-08 Richard Sandiford <richard@codesourcery.com> PR fortran/15326 |