public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [pushed] Revert "c++: restore instantiate_decl assert"
Date: Thu,  4 May 2023 21:07:07 -0400	[thread overview]
Message-ID: <20230505010707.2687333-1-jason@redhat.com> (raw)
In-Reply-To: <20230427014542.539011-1-jason@redhat.com>

Tested x86_64-pc-linux-gnu, applying to trunk.

-- 8< --

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                            |  6 ------
 gcc/testsuite/g++.dg/template/local10.C | 10 ++++++++++
 2 files changed, 10 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/template/local10.C

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 5446b5058b7..0f4fb258f9e 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -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
index 00000000000..9a70b846ff3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/local10.C
@@ -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); }

base-commit: 4657977541de1056a1cb651d6e2ba22472f62d04
-- 
2.31.1


      reply	other threads:[~2023-05-05  1:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27  1:45 [pushed] c++: restore instantiate_decl assert Jason Merrill
2023-05-05  1:07 ` Jason Merrill [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230505010707.2687333-1-jason@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).