commit 86b12872ec09b670b9be689d5c87c245b1745941
Author: Jason Merrill <jason@redhat.com>
Date: Thu May 29 17:22:36 2014 -0400
PR c++/56947
* pt.c (instantiate_decl): Check that defer_ok is not set for
local class members.
@@ -19696,6 +19696,11 @@ instantiate_decl (tree d, int defer_ok,
if (external_p && !always_instantiate_p (d))
return d;
+ /* Any local class members should be instantiated from the TAG_DEFN
+ with defer_ok == 0. */
+ gcc_checking_assert (!defer_ok || !decl_function_context (d)
+ || LAMBDA_TYPE_P (DECL_CONTEXT (d)));
+
gen_tmpl = most_general_template (tmpl);
gen_args = DECL_TI_ARGS (d);
new file mode 100644
@@ -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 >();