public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8502] c++: local class in generic lambda [PR113544]
@ 2024-01-29 17:40 Jason Merrill
  0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2024-01-29 17:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:77d3fb39c62558838c0e905df717903b5393dfc9

commit r14-8502-g77d3fb39c62558838c0e905df717903b5393dfc9
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jan 26 17:33:51 2024 -0500

    c++: local class in generic lambda [PR113544]
    
    My earlier commit r14-278-gd60cbbfaa9a3ad was a start toward better
    handling of local classes in generic lambdas, but isn't actually useful by
    itself and breaks this testcase, so let's revert it for now.
    
            PR c++/113544
    
    gcc/cp/ChangeLog:
    
            * pt.cc (instantiate_class_template): Don't partially instantiate.
            (tsubst_stmt): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1y/lambda-generic-nested3.C: New test.

Diff:
---
 gcc/cp/pt.cc                                        | 14 +++++---------
 gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C | 11 +++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index f5bf159a879f..fb2448a26e96 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -12226,8 +12226,7 @@ instantiate_class_template (tree type)
     return error_mark_node;
 
   if (COMPLETE_OR_OPEN_TYPE_P (type)
-      || (uses_template_parms (type)
-	  && !TYPE_FUNCTION_SCOPE_P (type)))
+      || uses_template_parms (type))
     return type;
 
   /* Figure out which template is being instantiated.  */
@@ -18893,7 +18892,10 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 
     case TAG_DEFN:
       tmp = tsubst (TREE_TYPE (t), args, complain, NULL_TREE);
-      if (CLASS_TYPE_P (tmp))
+      if (dependent_type_p (tmp))
+	/* This is a partial instantiation, try again when full.  */
+	add_stmt (build_min (TAG_DEFN, tmp));
+      else if (CLASS_TYPE_P (tmp))
 	{
 	  /* Local classes are not independent templates; they are
 	     instantiated along with their containing function.  And this
@@ -18902,12 +18904,6 @@ tsubst_stmt (tree t, tree args, tsubst_flags_t complain, tree in_decl)
 	  /* Closures are handled by the LAMBDA_EXPR.  */
 	  gcc_assert (!LAMBDA_TYPE_P (TREE_TYPE (t)));
 	  complete_type (tmp);
-	  if (dependent_type_p (tmp))
-	    {
-	      /* This is a partial instantiation, try again when full.  */
-	      add_stmt (build_min (TAG_DEFN, tmp));
-	      break;
-	    }
 	  tree save_ccp = current_class_ptr;
 	  tree save_ccr = current_class_ref;
 	  for (tree fld = TYPE_FIELDS (tmp); fld; fld = DECL_CHAIN (fld))
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C
new file mode 100644
index 000000000000..27655274a872
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-nested3.C
@@ -0,0 +1,11 @@
+// PR c++/113544
+// { dg-do compile { target c++14 } }
+
+template<class T>
+void f() {
+  [](auto parm) {
+    struct type : decltype(parm) { };
+  };
+}
+
+template void f<int>();

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-29 17:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-29 17:40 [gcc r14-8502] c++: local class in generic lambda [PR113544] Jason Merrill

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).