From 226a93b7b7e464dd4c030b75e1d118f0e382cde1 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 20 May 2015 17:32:52 -0400 Subject: [PATCH] pt.c (tsubst_decl): SET_DECL_IMPLICIT_INSTANTIATION before register_specialization. * pt.c (tsubst_decl) [VAR_DECL]: SET_DECL_IMPLICIT_INSTANTIATION before register_specialization. From-SVN: r223461 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 2 +- gcc/testsuite/g++.dg/cpp1y/var-templ27.C | 9 +++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp1y/var-templ27.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 320023a5ad8..b4c60b651cc 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2015-05-20 Jason Merrill + * pt.c (tsubst_decl) [VAR_DECL]: SET_DECL_IMPLICIT_INSTANTIATION + before register_specialization. + * decl.c (grok_op_properties): Don't complain about size_t placement delete here. * call.c (second_parm_is_size_t): Split out from... diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 60f395893ae..7555114ca6f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11407,9 +11407,9 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) processing here. */ DECL_EXTERNAL (r) = 1; - register_specialization (r, gen_tmpl, argvec, false, hash); DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec); SET_DECL_IMPLICIT_INSTANTIATION (r); + register_specialization (r, gen_tmpl, argvec, false, hash); } else if (!cp_unevaluated_operand) register_local_specialization (r, t); diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ27.C b/gcc/testsuite/g++.dg/cpp1y/var-templ27.C new file mode 100644 index 00000000000..da06b0123a9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ27.C @@ -0,0 +1,9 @@ +// { dg-do compile { target c++14 } } + +namespace A +{ + template int I = 0; + template int I = 42; +} + +int i = A::I; -- 2.30.2