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

* Re: [PATCH] c++: ICE with constrained placeholder return type [PR98346]
  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
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Merrill @ 2021-01-11 21:40 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches

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.

>   	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); }
> 


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

* Re: [PATCH] c++: ICE with constrained placeholder return type [PR98346]
  2021-01-11 21:40 ` Jason Merrill
@ 2021-01-11 22:08   ` Jason Merrill
  2021-01-15 16:37   ` Patrick Palka
  1 sibling, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2021-01-11 22:08 UTC (permalink / raw)
  To: Patrick Palka, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2064 bytes --]

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.

[-- Attachment #2: assert.patch --]
[-- Type: text/x-patch, Size: 653 bytes --]

commit 3825157b4d54c7f0f3e16f08b3dec5c271b01921
Author: Jason Merrill <jason@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);
 }

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

* Re: [PATCH] c++: ICE with constrained placeholder return type [PR98346]
  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
  1 sibling, 1 reply; 5+ messages in thread
From: Patrick Palka @ 2021-01-15 16:37 UTC (permalink / raw)
  To: Jason Merrill; +Cc: Patrick Palka, gcc-patches

On Mon, 11 Jan 2021, 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.

D'oh, good point..  We need to also substitute the template arguments of
the current instantiation into the constraint at some point.   This is
actually PR96443 / PR96444, which I reported and posted a patch for back
in August: https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551375.html

The approach the August patch used was to substitute into the
PLACEHOLDER_TYPE_CONSTRAINTS during tsubst, which was ruled out.  We can
instead do the same substitution during do_auto_deduction, as in the
patch below.  Does this approach look better?  It seems consistent with
how type_deducible_p substitutes into the return-type-requirement of a
compound-requirement.

Alternatively we could not substitute into PLACEHOLDER_TYPE_CONSTRAINTS
at all and instead pass the targs of the enclosing function directly
into satisfaction, but that seems inconsistent with type_deducible_p.

-- >8 --

Subject: [PATCH] c++: dependent constraint on placeholder return type
 [PR96443]

We're never substituting the template arguments of the enclosing
function into the constraint of a placeholder variable or return type,
which leads to errors during satisfaction when the constraint is
dependent.  This patch fixes this issue by doing the appropriate
substitution in do_auto_deduction before checking satisfaction.

Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
for trunk?  Also tested on cmcstl2 and range-v3.

gcc/cp/ChangeLog:

	PR c++/96443
	* pt.c (do_auto_deduction): Try checking the placeholder
	constraint template parse time.  Substitute the template
	arguments of the containing function into the placeholder
	constraint.  If the constraint is still dependent, defer
	deduction until instantiation time.

gcc/testsuite/ChangeLog:

	PR c++/96443
	* g++.dg/concepts/concepts-ts1.C: Add dg-bogus directive to the
	call to f15 that we expect to accept.
	* g++.dg/cpp2a/concepts-placeholder3.C: New test.
---
 gcc/cp/pt.c                                   | 19 ++++++++++++++++++-
 .../g++.dg/cpp2a/concepts-placeholder3.C      | 16 ++++++++++++++++
 gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C     |  2 +-
 3 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c6b7318b378..b70a9a451e1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -29455,7 +29455,7 @@ do_auto_deduction (tree type, tree init, tree auto_node,
     }
 
   /* Check any placeholder constraints against the deduced type. */
-  if (flag_concepts && !processing_template_decl)
+  if (flag_concepts)
     if (tree check = NON_ERROR (PLACEHOLDER_TYPE_CONSTRAINTS (auto_node)))
       {
         /* Use the deduced type to check the associated constraints. If we
@@ -29475,6 +29475,23 @@ do_auto_deduction (tree type, tree init, tree auto_node,
         else
           cargs = targs;
 
+	if ((context == adc_return_type || context == adc_variable_type)
+	    && current_function_decl
+	    && DECL_TEMPLATE_INFO (current_function_decl))
+	  {
+	    /* Substitute the template arguments of the enclosing function.  */
+	    cargs = tsubst_template_args (cargs,
+					  DECL_TI_ARGS (current_function_decl),
+					  complain, current_function_decl);
+	    if (cargs == error_mark_node)
+	      return error_mark_node;
+	  }
+
+	if (any_dependent_template_arguments_p (cargs))
+	  /* The constraint is dependent, so we can't complete the type
+	     deduction ahead of time.  */
+	  return type;
+
 	/* Rebuild the check using the deduced arguments.  */
 	check = build_concept_check (cdecl, cargs, tf_none);
 
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..abf5930e902
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C
@@ -0,0 +1,16 @@
+// PR c++/96443
+// { dg-do compile { target c++20 } }
+
+template <class T, class U> concept same_as = __is_same(T, U);
+
+auto f(auto x) -> same_as<decltype(x)> auto { return 0; }; // { dg-error "constraints" }
+void g(auto x) { same_as<decltype(x)> auto y = 0; } // { dg-error "constraints" }
+auto h(auto x) -> same_as<decltype(x.missing)> auto { return 0; } // { dg-error "missing" }
+
+int main() {
+  f(0); // { dg-bogus "" }
+  f(true); // { dg-message "required from here" }
+  g(0); // { dg-bogus "" }
+  g(true); // { dg-message "required from here" }
+  h(0); // { dg-message "required from here" }
+}
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
index 1cefe3b243f..a116cac4ea4 100644
--- a/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
@@ -40,7 +40,7 @@ void driver()
   f3('a'); // { dg-error "" }
   f4(0, 0);
   f4(0, 'a'); // { dg-error "" }
-  f15(0);
+  f15(0); // { dg-bogus "" }
   f15('a'); // { dg-message "" }
 }
 
-- 
2.30.0


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

* Re: [PATCH] c++: ICE with constrained placeholder return type [PR98346]
  2021-01-15 16:37   ` Patrick Palka
@ 2021-01-19 21:34     ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2021-01-19 21:34 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches

On 1/15/21 11:37 AM, Patrick Palka wrote:
> On Mon, 11 Jan 2021, 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.
> 
> D'oh, good point..  We need to also substitute the template arguments of
> the current instantiation into the constraint at some point.   This is
> actually PR96443 / PR96444, which I reported and posted a patch for back
> in August: https://gcc.gnu.org/pipermail/gcc-patches/2020-August/551375.html
> 
> The approach the August patch used was to substitute into the
> PLACEHOLDER_TYPE_CONSTRAINTS during tsubst, which was ruled out.  We can
> instead do the same substitution during do_auto_deduction, as in the
> patch below.  Does this approach look better?  It seems consistent with
> how type_deducible_p substitutes into the return-type-requirement of a
> compound-requirement.
> 
> Alternatively we could not substitute into PLACEHOLDER_TYPE_CONSTRAINTS
> at all and instead pass the targs of the enclosing function directly
> into satisfaction, but that seems inconsistent with type_deducible_p.

That sounds better.

I think type_deducible_p is wrong; 7.5.7.3-4 make it clear that this 
should work the same as other satisfaction.

> -- >8 --
> 
> Subject: [PATCH] c++: dependent constraint on placeholder return type
>   [PR96443]
> 
> We're never substituting the template arguments of the enclosing
> function into the constraint of a placeholder variable or return type,
> which leads to errors during satisfaction when the constraint is
> dependent.  This patch fixes this issue by doing the appropriate
> substitution in do_auto_deduction before checking satisfaction.
> 
> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK
> for trunk?  Also tested on cmcstl2 and range-v3.
> 
> gcc/cp/ChangeLog:
> 
> 	PR c++/96443
> 	* pt.c (do_auto_deduction): Try checking the placeholder
> 	constraint template parse time.  Substitute the template
> 	arguments of the containing function into the placeholder
> 	constraint.  If the constraint is still dependent, defer
> 	deduction until instantiation time.
> 
> gcc/testsuite/ChangeLog:
> 
> 	PR c++/96443
> 	* g++.dg/concepts/concepts-ts1.C: Add dg-bogus directive to the
> 	call to f15 that we expect to accept.
> 	* g++.dg/cpp2a/concepts-placeholder3.C: New test.
> ---
>   gcc/cp/pt.c                                   | 19 ++++++++++++++++++-
>   .../g++.dg/cpp2a/concepts-placeholder3.C      | 16 ++++++++++++++++
>   gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C     |  2 +-
>   3 files changed, 35 insertions(+), 2 deletions(-)
>   create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C
> 
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index c6b7318b378..b70a9a451e1 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -29455,7 +29455,7 @@ do_auto_deduction (tree type, tree init, tree auto_node,
>       }
>   
>     /* Check any placeholder constraints against the deduced type. */
> -  if (flag_concepts && !processing_template_decl)
> +  if (flag_concepts)
>       if (tree check = NON_ERROR (PLACEHOLDER_TYPE_CONSTRAINTS (auto_node)))
>         {
>           /* Use the deduced type to check the associated constraints. If we
> @@ -29475,6 +29475,23 @@ do_auto_deduction (tree type, tree init, tree auto_node,
>           else
>             cargs = targs;
>   
> +	if ((context == adc_return_type || context == adc_variable_type)
> +	    && current_function_decl
> +	    && DECL_TEMPLATE_INFO (current_function_decl))
> +	  {
> +	    /* Substitute the template arguments of the enclosing function.  */
> +	    cargs = tsubst_template_args (cargs,
> +					  DECL_TI_ARGS (current_function_decl),
> +					  complain, current_function_decl);
> +	    if (cargs == error_mark_node)
> +	      return error_mark_node;
> +	  }
> +
> +	if (any_dependent_template_arguments_p (cargs))
> +	  /* The constraint is dependent, so we can't complete the type
> +	     deduction ahead of time.  */
> +	  return type;
> +
>   	/* Rebuild the check using the deduced arguments.  */
>   	check = build_concept_check (cdecl, cargs, tf_none);
>   
> 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..abf5930e902
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-placeholder3.C
> @@ -0,0 +1,16 @@
> +// PR c++/96443
> +// { dg-do compile { target c++20 } }
> +
> +template <class T, class U> concept same_as = __is_same(T, U);
> +
> +auto f(auto x) -> same_as<decltype(x)> auto { return 0; }; // { dg-error "constraints" }
> +void g(auto x) { same_as<decltype(x)> auto y = 0; } // { dg-error "constraints" }
> +auto h(auto x) -> same_as<decltype(x.missing)> auto { return 0; } // { dg-error "missing" }
> +
> +int main() {
> +  f(0); // { dg-bogus "" }
> +  f(true); // { dg-message "required from here" }
> +  g(0); // { dg-bogus "" }
> +  g(true); // { dg-message "required from here" }
> +  h(0); // { dg-message "required from here" }
> +}
> diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C b/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
> index 1cefe3b243f..a116cac4ea4 100644
> --- a/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
> +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ts1.C
> @@ -40,7 +40,7 @@ void driver()
>     f3('a'); // { dg-error "" }
>     f4(0, 0);
>     f4(0, 'a'); // { dg-error "" }
> -  f15(0);
> +  f15(0); // { dg-bogus "" }
>     f15('a'); // { dg-message "" }
>   }
>   
> 


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