Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic

Message ID 20200619183925.4417-1-xerofoify@gmail.com
State New
Headers show
Series
  • Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
Related show

Commit Message

Richard Biener via Gcc-patches June 19, 2020, 6:39 p.m.
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.
Signed-off-by: Nicholas Krause <xerofoify@gmail.com>


Changelog:
*cp/type2ck.c: Add missing case TYPE_PACK_EXPANSION for diagnosticing
incomplete parameter pack expansion in cxx_incomplete_type_diagnostic
in order to avoid ICEing here.
---
 gcc/cp/typeck2.c | 5 +++++
 1 file changed, 5 insertions(+)

-- 
1.8.3.1

Comments

Richard Biener via Gcc-patches June 19, 2020, 9:40 p.m. | #1
On 6/19/20 2:39 PM, Nicholas Krause wrote:
> 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.

> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>

> 

> Changelog:

> *cp/type2ck.c: Add missing case TYPE_PACK_EXPANSION for diagnosticing


The filename is misspelled here; git gcc-verify would catch that for you.

"diagnosing".

> incomplete parameter pack expansion in cxx_incomplete_type_diagnostic

> in order to avoid ICEing here.


> ---

>   gcc/cp/typeck2.c | 5 +++++

>   1 file changed, 5 insertions(+)

> 

> diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c

> index 5fd3b82..dc5bd5e 100644

> --- a/gcc/cp/typeck2.c

> +++ b/gcc/cp/typeck2.c

> @@ -552,6 +552,11 @@ cxx_incomplete_type_diagnostic (location_t loc, const_tree value,

>   		       TYPE_NAME (type));

>         break;

>   

> +    case TYPE_PACK_EXPANSION:

> +     emit_diagnostic(diag_kind, loc, 0,


Space before (.

> +		     "invalid expansion of template expansion parameter %qT",


Let's just say "invalid use of pack expansion", there's no parameter here.

> +		      PACK_EXPANSION_PATTERN(type));


Space before (.

> +      break;


Blank line after break.

>       case TYPENAME_TYPE:

>       case DECLTYPE_TYPE:

>         emit_diagnostic (diag_kind, loc, 0,

> 


You also need to include the testcase in your patch.

Thanks,
Jason

Patch

diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 5fd3b82..dc5bd5e 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -552,6 +552,11 @@  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 expansion of template expansion parameter %qT",
+		      PACK_EXPANSION_PATTERN(type));
+      break;
     case TYPENAME_TYPE:
     case DECLTYPE_TYPE:
       emit_diagnostic (diag_kind, loc, 0,