summaryrefslogtreecommitdiff
path: root/gcc/cp/method.c
diff options
context:
space:
mode:
authormmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-29 00:16:05 +0000
committermmitchel <mmitchel@138bc75d-0d04-0410-961f-82ee72b054a4>2005-05-29 00:16:05 +0000
commit8223a66b225d8e45dfa90a3f657882683c3331f7 (patch)
tree33ff78e64cfd8923493efdc5cccd2b88af4a72ed /gcc/cp/method.c
parent9a755727a963ba66095e1e3ac618d7033c1353ed (diff)
downloadgcc-8223a66b225d8e45dfa90a3f657882683c3331f7.tar.gz
PR c++/21340
* method.c (implicitly_declare_fn): Clear processing_template_decl when generating implicit declaration. PR c++/21340 * g++.dg/init/ctor6.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@100306 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/method.c')
-rw-r--r--gcc/cp/method.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 37822bea78e..843f414bb9b 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -968,6 +968,19 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
tree raises = empty_except_spec;
tree rhs_parm_type = NULL_TREE;
tree name;
+ HOST_WIDE_INT saved_processing_template_decl;
+
+ /* Because we create declarations for implictly declared functions
+ lazily, we may be creating the declaration for a member of TYPE
+ while in some completely different context. However, TYPE will
+ never be a dependent class (because we never want to do lookups
+ for implicitly defined functions in a dependent class).
+ Furthermore, we must set PROCESSING_TEMPLATE_DECL to zero here
+ because we only create clones for constructors and destructors
+ when not in a template. */
+ gcc_assert (!dependent_type_p (type));
+ saved_processing_template_decl = processing_template_decl;
+ processing_template_decl = 0;
type = TYPE_MAIN_VARIANT (type);
@@ -1066,6 +1079,9 @@ implicitly_declare_fn (special_function_kind kind, tree type, bool const_p)
DECL_INLINE (fn) = 1;
gcc_assert (!TREE_USED (fn));
+ /* Restore PROCESSING_TEMPLATE_DECL. */
+ processing_template_decl = saved_processing_template_decl;
+
return fn;
}