]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Revert "c++: restore instantiate_decl assert"
authorJason Merrill <jason@redhat.com>
Thu, 4 May 2023 22:37:19 +0000 (18:37 -0400)
committerJason Merrill <jason@redhat.com>
Fri, 5 May 2023 01:07:19 +0000 (21:07 -0400)
In the testcase the assert fails because we use one member function from
another while we're in the middle of instantiating them all, which is
perfectly fine.  It seems complicated to detect this situation, so let's
remove the assert again.

PR c++/109658

This reverts commit 95d4c0d2e6318aef88ba0bc607dfc1ec6b7a612f.

gcc/testsuite/ChangeLog:

* g++.dg/template/local10.C: New test.

gcc/cp/pt.cc
gcc/testsuite/g++.dg/template/local10.C [new file with mode: 0644]

index 5446b5058b752ed10b993d6de478e43a30c07b24..0f4fb258f9ebc28fafd5d0bbd67b4114590783c0 100644 (file)
@@ -27061,12 +27061,6 @@ instantiate_decl (tree d, bool defer_ok, bool expl_inst_class_mem_p)
        pattern_defined = ! DECL_EXTERNAL (code_pattern);
     }
 
-  /* Any local class members should be instantiated from the TAG_DEFN
-     with defer_ok == 0.  */
-  gcc_checking_assert (!defer_ok || !pattern_defined
-                      || !decl_function_context (d)
-                      || LAMBDA_TYPE_P (DECL_CONTEXT (d)));
-
   /* We may be in the middle of deferred access check.  Disable it now.  */
   push_deferring_access_checks (dk_no_deferred);
 
diff --git a/gcc/testsuite/g++.dg/template/local10.C b/gcc/testsuite/g++.dg/template/local10.C
new file mode 100644 (file)
index 0000000..9a70b84
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/109658
+
+template <typename OutputStream> void encode(OutputStream, int *) {
+  struct ValueBaseVisitor {
+    void visit() { encodeString(); }
+    void encodeString() {}
+  };
+}
+int encode_json;
+void encode_out() { encode(encode_out, &encode_json); }