public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-10100] c++: dependent generic lambda template-id [PR106024]
Date: Fri,  1 Jul 2022 16:32:21 +0000 (GMT)	[thread overview]
Message-ID: <20220701163221.35E453851C32@sourceware.org> (raw)

https://gcc.gnu.org/g:252e9dfee9b1d01e0e44773ad83e0e44f3650945

commit r11-10100-g252e9dfee9b1d01e0e44773ad83e0e44f3650945
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jun 23 23:14:35 2022 -0400

    c++: dependent generic lambda template-id [PR106024]
    
    We were wrongly looking up the generic lambda op() in a dependent scope, and
    then trying to look up its instantiation at substitution time, but lambdas
    aren't instantiated, so we crashed.  The fix is to not look into dependent
    lambda scopes.
    
            PR c++/106024
    
    gcc/cp/ChangeLog:
    
            * parser.c (cp_parser_lookup_name): Don't look in dependent lambda.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/lambda-generic10.C: New test.

Diff:
---
 gcc/cp/parser.c                               |  5 ++++-
 gcc/testsuite/g++.dg/cpp2a/lambda-generic10.C | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index b53cc6d360e..94b10922b90 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -29434,9 +29434,12 @@ cp_parser_lookup_name (cp_parser *parser, tree name,
     }
   else if (object_type)
     {
+      bool dep = dependent_scope_p (object_type);
+
       /* Look up the name in the scope of the OBJECT_TYPE, unless the
 	 OBJECT_TYPE is not a class.  */
-      if (CLASS_TYPE_P (object_type))
+      if (CLASS_TYPE_P (object_type)
+	  && !(dep && LAMBDA_TYPE_P (object_type)))
 	/* If the OBJECT_TYPE is a template specialization, it may
 	   be instantiated during name lookup.  In that case, errors
 	   may be issued.  Even if we rollback the current tentative
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-generic10.C b/gcc/testsuite/g++.dg/cpp2a/lambda-generic10.C
new file mode 100644
index 00000000000..773fb948cee
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-generic10.C
@@ -0,0 +1,14 @@
+// PR c++/106024
+// { dg-do compile { target c++20 } }
+
+void sink(...);
+template <int... args> void f()
+{
+  sink ([] <int T> (int...) { return 1; }
+        .operator()<args>(args...)...); // { dg-error "" }
+} // { dg-prune-output {expected '\)'} }
+
+int main()
+{
+  f<1,2,3>();
+}


                 reply	other threads:[~2022-07-01 16:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220701163221.35E453851C32@sourceware.org \
    --to=jason@gcc.gnu.org \
    --cc=gcc-cvs@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).