From: Jason Merrill Date: Fri, 12 Jun 2015 18:16:22 +0000 (-0400) Subject: re PR c++/65719 (Link error with constexpr variable template) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=350562a75dfb4ac658adf620665871eb47166652;p=gcc.git re PR c++/65719 (Link error with constexpr variable template) PR c++/65719 * pt.c (tsubst_decl) [VAR_DECL]: Mark namespace-scope variables as DECL_NOT_REALLY_EXTERN. From-SVN: r224442 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 39b5a08fe8f..b18a893a2ca 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-06-12 Jason Merrill + + PR c++/65719 + * pt.c (tsubst_decl) [VAR_DECL]: Mark namespace-scope + variables as DECL_NOT_REALLY_EXTERN. + 2015-06-11 Jason Merrill PR c++/66445 diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 7f04fe618b4..ea8c8b65a3f 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11306,8 +11306,7 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) { /* T is a static data member or namespace-scope entity. We have to substitute into namespace-scope variables - (even though such entities are never templates) because - of cases like: + (not just variable templates) because of cases like: template void f() { extern T t; } @@ -11468,6 +11467,8 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) initializer is present. We mimic the non-template processing here. */ DECL_EXTERNAL (r) = 1; + if (DECL_NAMESPACE_SCOPE_P (t)) + DECL_NOT_REALLY_EXTERN (r) = 1; DECL_TEMPLATE_INFO (r) = build_template_info (tmpl, argvec); SET_DECL_IMPLICIT_INSTANTIATION (r); diff --git a/gcc/testsuite/g++.dg/cpp1y/var-templ29.C b/gcc/testsuite/g++.dg/cpp1y/var-templ29.C new file mode 100644 index 00000000000..22f5b0bc093 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1y/var-templ29.C @@ -0,0 +1,13 @@ +// PR c++/65719 +// { dg-do link { target c++14 } } + +struct FunctionObject { + void operator()() const { } +}; + +template +constexpr FunctionObject f{}; + +int main() { + f(); +}