From: Jason Merrill Date: Fri, 30 May 2014 15:09:29 +0000 (-0400) Subject: re PR c++/56947 (Bogus 'XX' was not declared in this scope) X-Git-Tag: releases/gcc-4.7.4~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f7169686130024a8062f4703576f04bef86ff37;p=thirdparty%2Fgcc.git re PR c++/56947 (Bogus 'XX' was not declared in this scope) PR c++/56947 * pt.c (instantiate_decl): Don't defer instantiation of a nested function. From-SVN: r211083 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 1ee383f8b09e..e8afee663421 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2014-05-30 Jason Merrill + + PR c++/56947 + * pt.c (instantiate_decl): Don't defer instantiation of a nested + function. + 2014-05-07 Jakub Jelinek Backported from mainline diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index f2b2f9bccf93..e1cc59d5e46b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -18191,6 +18191,7 @@ instantiate_decl (tree d, int defer_ok, if the variable has a constant value the referring expression can take advantage of that fact. */ if (TREE_CODE (d) == VAR_DECL + || decl_function_context (d) || DECL_DECLARED_CONSTEXPR_P (d)) defer_ok = 0; diff --git a/gcc/testsuite/g++.dg/template/local8.C b/gcc/testsuite/g++.dg/template/local8.C new file mode 100644 index 000000000000..006bd8c40eb3 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local8.C @@ -0,0 +1,18 @@ +// PR c++/56947 + +struct A +{ + A (int); +}; + +template < typename > +void Fn () +{ + const int kCapacity = 0; + struct Q:A + { + Q ():A (kCapacity) { } + }; + Q q; +} +template void Fn < int >();