]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/56947 (Bogus 'XX' was not declared in this scope)
authorJason Merrill <jason@redhat.com>
Fri, 30 May 2014 15:09:29 +0000 (11:09 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 30 May 2014 15:09:29 +0000 (11:09 -0400)
PR c++/56947
* pt.c (instantiate_decl): Don't defer instantiation of a nested
function.

From-SVN: r211083

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.dg/template/local8.C [new file with mode: 0644]

index 1ee383f8b09eadbcacfd2615314fd89513826332..e8afee663421376e78e8edf15ac17d270ed10897 100644 (file)
@@ -1,3 +1,9 @@
+2014-05-30  Jason Merrill  <jason@redhat.com>
+
+       PR c++/56947
+       * pt.c (instantiate_decl): Don't defer instantiation of a nested
+       function.
+
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index f2b2f9bccf938e65d4d24d3d3b01c387ee3aea40..e1cc59d5e46b84b02b03a00ff00d5015dad8728a 100644 (file)
@@ -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 (file)
index 0000000..006bd8c
--- /dev/null
@@ -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 >();