public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c++: ICE with constrained placeholder return type [PR98346]
@ 2021-01-07 21:06 Patrick Palka
  2021-01-11 21:40 ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Patrick Palka @ 2021-01-07 21:06 UTC (permalink / raw)
  To: gcc-patches

This is essentially a followup to r11-3714 -- we ICEing from another
"unguarded" call to build_concept_check, this time in do_auto_deduction,
due to the presence of templated trees when !processing_template_decl.

Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for
trunk and perhaps the 10 branch?

gcc/cp/ChangeLog:

	PR c++/98346
	* pt.c (do_auto_deduction): Temporarily increment
	processing_template_decl before calling build_concept_check.

gcc/testsuite/ChangeLog:

	PR c++/98346
	* g++.dg/cpp2a/concepts-placeholder3.C: New test.
---
 gcc/cp/pt.c                                       |  2 ++
 .../g++.dg/cpp2a/concepts-placeholder3.C          | 15 +++++++++++++++
 2 files changed, 17 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index beabcc4b027..111a694e0c5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -29464,7 +29464,9 @@ do_auto_deduction (tree type, tree init, tree auto_node,
           cargs = targs;
 
 	/* Rebuild the check using the deduced arguments.  */
+	++processing_template_decl;
 	check = build_concept_check (cdecl, cargs, tf_none);
+	--processing_template_decl;
 
 	if (!constraints_satisfied_p (check))
           {
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C
new file mode 100644
index 00000000000..a5d0b1e1d0f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C
@@ -0,0 +1,15 @@
+// PR c++/98346
+// { dg-do compile { target c++20 } }
+
+template <class, class...>
+concept always_satisfied = true;
+
+using arg_alias = int;
+
+template <always_satisfied F>
+using result_of = decltype(F{}(arg_alias{}));
+
+template <class F>
+always_satisfied<result_of<F>> auto foo(F) {}
+
+void bar() { foo(0); }
-- 
2.30.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-19 21:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 21:06 [PATCH] c++: ICE with constrained placeholder return type [PR98346] Patrick Palka
2021-01-11 21:40 ` Jason Merrill
2021-01-11 22:08   ` Jason Merrill
2021-01-15 16:37   ` Patrick Palka
2021-01-19 21:34     ` 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).