]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: restore instantiate_decl assert
authorJason Merrill <jason@redhat.com>
Thu, 16 Mar 2023 20:55:39 +0000 (16:55 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 27 Apr 2023 01:46:00 +0000 (21:46 -0400)
For PR61445 I removed this assert, but PR108242 demonstrated why it's still
useful; to avoid regressing the former testcase I check pattern_defined
in the assert.

This reverts r212524.

PR c++/61445

gcc/cp/ChangeLog:

* pt.cc (instantiate_decl): Assert !defer_ok for local
class members.

gcc/cp/pt.cc

index 93a055c66a1ece053bf38bb236e50341617d075b..6df16fef0dd38b0ba8411f7b6d2590a3f5365fc5 100644 (file)
@@ -27090,6 +27090,12 @@ 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);