public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
@ 2020-06-23  1:42 Nicholas Krause
  2020-06-23  2:01 ` Marek Polacek
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Krause @ 2020-06-23  1:42 UTC (permalink / raw)
  To: jason; +Cc: gcc-patches

From: Nicholas Krause <xerofoify@gmail.com>

This fixs the PR95672 by adding the missing TYPE_PACK_EXPANSION case in
cxx_incomplete_type_diagnostic in order to avoid ICES on diagnosing
incomplete template pack expansion cases. In v2, add the missing required
test case for all new patches. v3 Fixes both the test case to compile in
C++11 mode and the message to print out only the type. v4 fixes the testcase
to only target C++11. v5 and v6 fix the test case properly.

gcc/cp/ChangeLog:

	* typeck2.c (cxx_incomplete_type_diagnostic): Add missing TYPE_EXPANSION_PACK
	  check for diagnosticing incomplete types in cxx_incomplete_type_diagnostic.

gcc/testsuite/ChangeLog:

	* g++.dg/template/PR95672.C: New test.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 gcc/cp/typeck2.c                        | 6 ++++++
 gcc/testsuite/g++.dg/template/PR95672.C | 3 +++
 2 files changed, 9 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/template/PR95672.C

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 5fd3b82fa89..28b32fe0b5a 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -552,6 +552,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
 		       TYPE_NAME (type));
       break;
 
+    case TYPE_PACK_EXPANSION:
+     emit_diagnostic (diag_kind, loc, 0,
+		     "invalid use of pack expansion %qT",
+		      type);
+      break;
+
     case TYPENAME_TYPE:
     case DECLTYPE_TYPE:
       emit_diagnostic (diag_kind, loc, 0,
diff --git a/gcc/testsuite/g++.dg/template/PR95672.C b/gcc/testsuite/g++.dg/template/PR95672.C
new file mode 100644
index 00000000000..fcc3da0a132
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/PR95672.C
@@ -0,0 +1,3 @@
+// PR c++/96572 
+// { dg-do compile}
+// { dg-options "-std=c++11" }
+struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }
-- 
2.20.1


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

* Re: [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
  2020-06-23  1:42 [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic Nicholas Krause
@ 2020-06-23  2:01 ` Marek Polacek
  2020-06-23  3:11   ` Nicholas Krause
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Polacek @ 2020-06-23  2:01 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: jason, gcc-patches

On Mon, Jun 22, 2020 at 09:42:51PM -0400, Nicholas Krause via Gcc-patches wrote:
> From: Nicholas Krause <xerofoify@gmail.com>
> 
> This fixs the PR95672 by adding the missing TYPE_PACK_EXPANSION case in
> cxx_incomplete_type_diagnostic in order to avoid ICES on diagnosing
> incomplete template pack expansion cases. In v2, add the missing required
> test case for all new patches. v3 Fixes both the test case to compile in
> C++11 mode and the message to print out only the type. v4 fixes the testcase
> to only target C++11. v5 and v6 fix the test case properly.
> 
> gcc/cp/ChangeLog:
> 
> 	* typeck2.c (cxx_incomplete_type_diagnostic): Add missing TYPE_EXPANSION_PACK
> 	  check for diagnosticing incomplete types in cxx_incomplete_type_diagnostic.

It's already been pointed out to you that it's "diagnosing".

> gcc/testsuite/ChangeLog:
> 
> 	* g++.dg/template/PR95672.C: New test.
> 
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
>  gcc/cp/typeck2.c                        | 6 ++++++
>  gcc/testsuite/g++.dg/template/PR95672.C | 3 +++
>  2 files changed, 9 insertions(+)
>  create mode 100644 gcc/testsuite/g++.dg/template/PR95672.C
> 
> diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
> index 5fd3b82fa89..28b32fe0b5a 100644
> --- a/gcc/cp/typeck2.c
> +++ b/gcc/cp/typeck2.c
> @@ -552,6 +552,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
>  		       TYPE_NAME (type));
>        break;
>  
> +    case TYPE_PACK_EXPANSION:
> +     emit_diagnostic (diag_kind, loc, 0,

Bad indenting.

> +		     "invalid use of pack expansion %qT",
> +		      type);
> +      break;
> +
>      case TYPENAME_TYPE:
>      case DECLTYPE_TYPE:
>        emit_diagnostic (diag_kind, loc, 0,
> diff --git a/gcc/testsuite/g++.dg/template/PR95672.C b/gcc/testsuite/g++.dg/template/PR95672.C
> new file mode 100644
> index 00000000000..fcc3da0a132
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/template/PR95672.C
> @@ -0,0 +1,3 @@
> +// PR c++/96572 
> +// { dg-do compile}
> +// { dg-options "-std=c++11" }
> +struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }

No, this is completely broken.  It passes only because the patch file is
malformed and the last line will be lost when applying the patch, so the
test is an empty file.

Marek


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

* Re: [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
  2020-06-23  2:01 ` Marek Polacek
@ 2020-06-23  3:11   ` Nicholas Krause
  2020-06-23 12:27     ` Marek Polacek
  0 siblings, 1 reply; 5+ messages in thread
From: Nicholas Krause @ 2020-06-23  3:11 UTC (permalink / raw)
  To: Marek Polacek; +Cc: jason, gcc-patches



On 6/22/20 10:01 PM, Marek Polacek wrote:
> On Mon, Jun 22, 2020 at 09:42:51PM -0400, Nicholas Krause via Gcc-patches wrote:
>> From: Nicholas Krause <xerofoify@gmail.com>
>>
>> This fixs the PR95672 by adding the missing TYPE_PACK_EXPANSION case in
>> cxx_incomplete_type_diagnostic in order to avoid ICES on diagnosing
>> incomplete template pack expansion cases. In v2, add the missing required
>> test case for all new patches. v3 Fixes both the test case to compile in
>> C++11 mode and the message to print out only the type. v4 fixes the testcase
>> to only target C++11. v5 and v6 fix the test case properly.
>>
>> gcc/cp/ChangeLog:
>>
>> 	* typeck2.c (cxx_incomplete_type_diagnostic): Add missing TYPE_EXPANSION_PACK
>> 	  check for diagnosticing incomplete types in cxx_incomplete_type_diagnostic.
> 
> It's already been pointed out to you that it's "diagnosing".
> 
>> gcc/testsuite/ChangeLog:
>>
>> 	* g++.dg/template/PR95672.C: New test.
>>
>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
>> ---
>>   gcc/cp/typeck2.c                        | 6 ++++++
>>   gcc/testsuite/g++.dg/template/PR95672.C | 3 +++
>>   2 files changed, 9 insertions(+)
>>   create mode 100644 gcc/testsuite/g++.dg/template/PR95672.C
>>
>> diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
>> index 5fd3b82fa89..28b32fe0b5a 100644
>> --- a/gcc/cp/typeck2.c
>> +++ b/gcc/cp/typeck2.c
>> @@ -552,6 +552,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
>>   		       TYPE_NAME (type));
>>         break;
>>   
>> +    case TYPE_PACK_EXPANSION:
>> +     emit_diagnostic (diag_kind, loc, 0,
> 
> Bad indenting.

Sorry seems Jason didn't catch that.
> 
>> +		     "invalid use of pack expansion %qT",
>> +		      type);
>> +      break;
>> +
>>       case TYPENAME_TYPE:
>>       case DECLTYPE_TYPE:
>>         emit_diagnostic (diag_kind, loc, 0,
>> diff --git a/gcc/testsuite/g++.dg/template/PR95672.C b/gcc/testsuite/g++.dg/template/PR95672.C
>> new file mode 100644
>> index 00000000000..fcc3da0a132
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/template/PR95672.C
>> @@ -0,0 +1,3 @@
>> +// PR c++/96572
>> +// { dg-do compile}
>> +// { dg-options "-std=c++11" }
>> +struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }
> 
> No, this is completely broken.  It passes only because the patch file is
> malformed and the last line will be lost when applying the patch, so the
> test is an empty file.
> 
> Marek
> 

Yes but now that I look at it seems the issue is that the error message 
was changed. My concern is that the test will have to be updated
from the current every time the message changes like the current:
error: expected primary-expression before ‘auto’
     1 | struct g_class : decltype  (auto) ... {  };

Is this something I should care about as seems emit_diagnostic and 
friends sometimes do this.

Thanks,
Nick

-- 
Fundamentally an organism has conscious mental states if and only if 
there is something that it is like to be that organism--something it is 
like for the organism. - Thomas Nagel

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

* Re: [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
  2020-06-23  3:11   ` Nicholas Krause
@ 2020-06-23 12:27     ` Marek Polacek
  2020-06-23 18:17       ` Jason Merrill
  0 siblings, 1 reply; 5+ messages in thread
From: Marek Polacek @ 2020-06-23 12:27 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: jason, gcc-patches

On Mon, Jun 22, 2020 at 11:11:48PM -0400, Nicholas Krause wrote:
> 
> 
> On 6/22/20 10:01 PM, Marek Polacek wrote:
> > On Mon, Jun 22, 2020 at 09:42:51PM -0400, Nicholas Krause via Gcc-patches wrote:
> > > From: Nicholas Krause <xerofoify@gmail.com>
> > > 
> > > This fixs the PR95672 by adding the missing TYPE_PACK_EXPANSION case in
> > > cxx_incomplete_type_diagnostic in order to avoid ICES on diagnosing
> > > incomplete template pack expansion cases. In v2, add the missing required
> > > test case for all new patches. v3 Fixes both the test case to compile in
> > > C++11 mode and the message to print out only the type. v4 fixes the testcase
> > > to only target C++11. v5 and v6 fix the test case properly.
> > > 
> > > gcc/cp/ChangeLog:
> > > 
> > > 	* typeck2.c (cxx_incomplete_type_diagnostic): Add missing TYPE_EXPANSION_PACK
> > > 	  check for diagnosticing incomplete types in cxx_incomplete_type_diagnostic.
> > 
> > It's already been pointed out to you that it's "diagnosing".
> > 
> > > gcc/testsuite/ChangeLog:
> > > 
> > > 	* g++.dg/template/PR95672.C: New test.
> > > 
> > > Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> > > ---
> > >   gcc/cp/typeck2.c                        | 6 ++++++
> > >   gcc/testsuite/g++.dg/template/PR95672.C | 3 +++
> > >   2 files changed, 9 insertions(+)
> > >   create mode 100644 gcc/testsuite/g++.dg/template/PR95672.C
> > > 
> > > diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
> > > index 5fd3b82fa89..28b32fe0b5a 100644
> > > --- a/gcc/cp/typeck2.c
> > > +++ b/gcc/cp/typeck2.c
> > > @@ -552,6 +552,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
> > >   		       TYPE_NAME (type));
> > >         break;
> > > +    case TYPE_PACK_EXPANSION:
> > > +     emit_diagnostic (diag_kind, loc, 0,
> > 
> > Bad indenting.
> 
> Sorry seems Jason didn't catch that.
> > 
> > > +		     "invalid use of pack expansion %qT",
> > > +		      type);
> > > +      break;
> > > +
> > >       case TYPENAME_TYPE:
> > >       case DECLTYPE_TYPE:
> > >         emit_diagnostic (diag_kind, loc, 0,
> > > diff --git a/gcc/testsuite/g++.dg/template/PR95672.C b/gcc/testsuite/g++.dg/template/PR95672.C
> > > new file mode 100644
> > > index 00000000000..fcc3da0a132
> > > --- /dev/null
> > > +++ b/gcc/testsuite/g++.dg/template/PR95672.C
> > > @@ -0,0 +1,3 @@
> > > +// PR c++/96572
> > > +// { dg-do compile}
> > > +// { dg-options "-std=c++11" }
> > > +struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }
> > 
> > No, this is completely broken.  It passes only because the patch file is
> > malformed and the last line will be lost when applying the patch, so the
> > test is an empty file.
> > 
> > Marek
> > 
> 
> Yes but now that I look at it seems the issue is that the error message was
> changed. My concern is that the test will have to be updated
> from the current every time the message changes like the current:
> error: expected primary-expression before ‘auto’
>     1 | struct g_class : decltype  (auto) ... {  };
> 
> Is this something I should care about as seems emit_diagnostic and friends
> sometimes do this.

decltype(auto) is a C++14 feature so won't work with -std=c++11.

Marek


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

* Re: [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
  2020-06-23 12:27     ` Marek Polacek
@ 2020-06-23 18:17       ` Jason Merrill
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Merrill @ 2020-06-23 18:17 UTC (permalink / raw)
  To: Marek Polacek, Nicholas Krause; +Cc: gcc-patches

On 6/23/20 8:27 AM, Marek Polacek wrote:
> On Mon, Jun 22, 2020 at 11:11:48PM -0400, Nicholas Krause wrote:
>>
>>
>> On 6/22/20 10:01 PM, Marek Polacek wrote:
>>> On Mon, Jun 22, 2020 at 09:42:51PM -0400, Nicholas Krause via Gcc-patches wrote:
>>>> From: Nicholas Krause <xerofoify@gmail.com>
>>>>
>>>> This fixs the PR95672 by adding the missing TYPE_PACK_EXPANSION case in
>>>> cxx_incomplete_type_diagnostic in order to avoid ICES on diagnosing
>>>> incomplete template pack expansion cases. In v2, add the missing required
>>>> test case for all new patches. v3 Fixes both the test case to compile in
>>>> C++11 mode and the message to print out only the type. v4 fixes the testcase
>>>> to only target C++11. v5 and v6 fix the test case properly.
>>>>
>>>> gcc/cp/ChangeLog:
>>>>
>>>> 	* typeck2.c (cxx_incomplete_type_diagnostic): Add missing TYPE_EXPANSION_PACK
>>>> 	  check for diagnosticing incomplete types in cxx_incomplete_type_diagnostic.
>>>
>>> It's already been pointed out to you that it's "diagnosing".
>>>
>>>> gcc/testsuite/ChangeLog:
>>>>
>>>> 	* g++.dg/template/PR95672.C: New test.
>>>>
>>>> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
>>>> ---
>>>>    gcc/cp/typeck2.c                        | 6 ++++++
>>>>    gcc/testsuite/g++.dg/template/PR95672.C | 3 +++
>>>>    2 files changed, 9 insertions(+)
>>>>    create mode 100644 gcc/testsuite/g++.dg/template/PR95672.C
>>>>
>>>> diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
>>>> index 5fd3b82fa89..28b32fe0b5a 100644
>>>> --- a/gcc/cp/typeck2.c
>>>> +++ b/gcc/cp/typeck2.c
>>>> @@ -552,6 +552,12 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,
>>>>    		       TYPE_NAME (type));
>>>>          break;
>>>> +    case TYPE_PACK_EXPANSION:
>>>> +     emit_diagnostic (diag_kind, loc, 0,
>>>
>>> Bad indenting.
>>
>> Sorry seems Jason didn't catch that.
>>>
>>>> +		     "invalid use of pack expansion %qT",
>>>> +		      type);
>>>> +      break;
>>>> +
>>>>        case TYPENAME_TYPE:
>>>>        case DECLTYPE_TYPE:
>>>>          emit_diagnostic (diag_kind, loc, 0,
>>>> diff --git a/gcc/testsuite/g++.dg/template/PR95672.C b/gcc/testsuite/g++.dg/template/PR95672.C
>>>> new file mode 100644
>>>> index 00000000000..fcc3da0a132
>>>> --- /dev/null
>>>> +++ b/gcc/testsuite/g++.dg/template/PR95672.C
>>>> @@ -0,0 +1,3 @@
>>>> +// PR c++/96572
>>>> +// { dg-do compile}
>>>> +// { dg-options "-std=c++11" }
>>>> +struct g_class : decltype  (auto) ... {  }; // { dg-error "invalid use of pack expansion" }
>>>
>>> No, this is completely broken.  It passes only because the patch file is
>>> malformed and the last line will be lost when applying the patch, so the
>>> test is an empty file.
>>>
>>> Marek
>>>
>>
>> Yes but now that I look at it seems the issue is that the error message was
>> changed. My concern is that the test will have to be updated
>> from the current every time the message changes like the current:
>> error: expected primary-expression before ‘auto’
>>      1 | struct g_class : decltype  (auto) ... {  };
>>
>> Is this something I should care about as seems emit_diagnostic and friends
>> sometimes do this.
> 
> decltype(auto) is a C++14 feature so won't work with -std=c++11.

Yes, and so in C++11 mode you get a different error.

Better like in your v5 patch to use

> +// { dg-do compile { target c++11 } }

because that means "run for C++11 and above", whereas the dg-options 
line makes it run only in C++11 mode.

But since as Marek points out you're testing a C++14 feature, probably 
beter to use

// { dg-do compile { target c++14 } }

unless you really want to test for different errors in different modes.

Jason


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

end of thread, other threads:[~2020-06-23 18:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-23  1:42 [PATCHv6] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic Nicholas Krause
2020-06-23  2:01 ` Marek Polacek
2020-06-23  3:11   ` Nicholas Krause
2020-06-23 12:27     ` Marek Polacek
2020-06-23 18:17       ` 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).