public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-9437] c++: generic lambda, local class, __func__ [PR108242]
@ 2023-04-18 20:46 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2023-04-18 20:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:890d711a2477119a34cf435f6159b6253b124374
commit r12-9437-g890d711a2477119a34cf435f6159b6253b124374
Author: Jason Merrill <jason@redhat.com>
Date: Thu Mar 16 15:11:25 2023 -0400
c++: generic lambda, local class, __func__ [PR108242]
Here we are trying to do name lookup in a deferred instantiation of t() and
failing to find __func__. tsubst_expr already tries to instantiate members
of local classes, but was failing with the partial instantiation of generic
lambdas.
PR c++/108242
gcc/cp/ChangeLog:
* pt.cc (tsubst_expr) [TAG_DEFN]: Handle partial instantiation.
gcc/testsuite/ChangeLog:
* g++.dg/cpp1y/lambda-generic-func2.C: New test.
Diff:
---
gcc/cp/pt.cc | 5 ++++-
gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 4d6c6bfb8cf..a9c57e5d45a 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -19090,7 +19090,10 @@ tsubst_expr (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
diff --git a/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C
new file mode 100644
index 00000000000..ed541c7812f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/lambda-generic-func2.C
@@ -0,0 +1,18 @@
+// PR c++/108242
+// { dg-do compile { target c++14 } }
+
+template<int F>
+void my_fun()
+{
+ [&](auto) {
+ static constexpr char const* fun_name = __func__;
+ struct t
+ {
+ t() { fun_name; };
+ } t1;
+ }(12);
+}
+
+int main() {
+ my_fun<1>();
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-18 20:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 20:46 [gcc r12-9437] c++: generic lambda, local class, __func__ [PR108242] 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).