On 1/11/21 4:40 PM, Jason Merrill wrote:
On 1/7/21 4:06 PM, Patrick Palka wrote:
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;

This shouldn't be necessary; if processing_template_decl is 0, we should have non-dependent args.

I think your patch only works for this testcase because the concept is trivial and doesn't actually try to to do anything with the arguments.

Handling of PLACEHOLDER_TYPE_CONSTRAINTS is overly complex, partly because the 'auto' is represented as an argument in its own constraints.

A constrained auto variable declaration has the same problem.

Appling the patch below turns up similar problems in a couple of existing testcases.
commit 3825157b4d54c7f0f3e16f08b3dec5c271b01921
Author: Jason Merrill <ja...@redhat.com>
Date:   Mon Jan 11 16:45:16 2021 -0500

    assert

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 9049d087859..1d87c7e48a3 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3069,6 +3069,9 @@ satisfy_constraint_expression (tree t, tree args, sat_info info)
   else
     norm = normalize_constraint_expression (t, info.noisy ());
 
+  /* Satisfaction can only be determined with real args.  */
+  gcc_checking_assert (!uses_template_parms (args));
+
   /* Perform satisfaction.  */
   return satisfy_constraint (norm, args, info);
 }

Reply via email to