[PATCHv3] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic

Message ID 20200620182626.7647-1-xerofoify@gmail.com
State Superseded
Headers show
Series
  • [PATCHv3] Handle TYPE_PACK_EXPANSION in cxx_incomplete_type_diagnostic
Related show

Commit Message

Christophe Lyon via Gcc-patches June 20, 2020, 6:26 p.m.
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.

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

Changelog:
*gcc/cp/typeck2.c: Add missing case TYPE_PACK_EXPANSION for diagnosing
incomplete parameter pack expansion in cxx_incomplete_type_diagnostic
in order to avoid ICEing here.
*gcc/testsuite/g++.db/template/PR95672.C:Add new testcase for PR95672.
---
 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

-- 
2.20.1

Comments

Christophe Lyon via Gcc-patches June 21, 2020, 4:55 p.m. | #1
On 6/20/20 2:26 PM, Nicholas Krause 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.

> 

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

> Changelog:

> *gcc/cp/typeck2.c: Add missing case TYPE_PACK_EXPANSION for diagnosing

> incomplete parameter pack expansion in cxx_incomplete_type_diagnostic

> in order to avoid ICEing here.

> *gcc/testsuite/g++.db/template/PR95672.C:Add new testcase for PR95672.


This still doesn't satisfy git gcc-verify.  Try using

   git gcc-commit-mklog --amend

to add a suitable ChangeLog skeleton.  You may need to run 
contrib/gcc-git-customization.sh first.

> ---

>   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..8795c13f365

> --- /dev/null

> +++ b/gcc/testsuite/g++.dg/template/PR95672.C

> @@ -0,0 +1,3 @@

> +//c++ PR96572

> +// {dg-options "-std=c++11"}

> +struct g_class : decltype  (auto) ... {  } ; { dg-error "invalid use of pack expansion" }


This test still fails.

Jason

Patch

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..8795c13f365
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/PR95672.C
@@ -0,0 +1,3 @@ 
+//c++ PR96572 
+// {dg-options "-std=c++11"}
+struct g_class : decltype  (auto) ... {  } ; { dg-error "invalid use of pack expansion" }