[C++] PR 90173 ("[9 Regression] ICE: Segmentation fault (in strip_declarator_types)")

Message ID 9ff40523-40e5-bca7-b525-7571f45a791b@oracle.com
State New
Headers show
Series
  • [C++] PR 90173 ("[9 Regression] ICE: Segmentation fault (in strip_declarator_types)")
Related show

Commit Message

Paolo Carlini April 23, 2019, 3:25 p.m.
Hi,

I tried a few different things to avoid this simple error-recovery 
regression but, all in all, I think it makes sense to simply bail out 
early from grokdeclarator upon the first error. Tested x86_64-linux.

Thanks, Paolo.

///////////////////
/cp
2019-04-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/90173
	* decl.c (grokdeclarator): Early return error_mark_node
	upon error about template placeholder type non followed
	by a simple declarator-id.

/testsuite
2019-04-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/90173
	* g++.dg/cpp1z/class-deduction66.C: New.

Comments

Jason Merrill April 25, 2019, 9:14 p.m. | #1
On Tue, Apr 23, 2019 at 11:26 AM Paolo Carlini <paolo.carlini@oracle.com> wrote:
>

> I tried a few different things to avoid this simple error-recovery

> regression but, all in all, I think it makes sense to simply bail out

> early from grokdeclarator upon the first error. Tested x86_64-linux.


"type = error_mark_node" doesn't work?

Jason
Paolo Carlini April 25, 2019, 11:14 p.m. | #2
Hi,

On 25/04/19 23:14, Jason Merrill wrote:
> On Tue, Apr 23, 2019 at 11:26 AM Paolo Carlini <paolo.carlini@oracle.com> wrote:

>> I tried a few different things to avoid this simple error-recovery

>> regression but, all in all, I think it makes sense to simply bail out

>> early from grokdeclarator upon the first error. Tested x86_64-linux.

> "type = error_mark_node" doesn't work?


Yes, it passes testing and appears to work fine: in practice for the new 
testcase grokdeclarator doesn't issue any further diagnostic and returns 
error_mark_node a few lines below, around line # 11256. Shall we apply 
this version to gcc-9-branch too?

Thanks! Paolo.
Jason Merrill April 26, 2019, 2:31 p.m. | #3
On 4/25/19 7:14 PM, Paolo Carlini wrote:
> Hi,

> 

> On 25/04/19 23:14, Jason Merrill wrote:

>> On Tue, Apr 23, 2019 at 11:26 AM Paolo Carlini 

>> <paolo.carlini@oracle.com> wrote:

>>> I tried a few different things to avoid this simple error-recovery

>>> regression but, all in all, I think it makes sense to simply bail out

>>> early from grokdeclarator upon the first error. Tested x86_64-linux.

>> "type = error_mark_node" doesn't work?

> 

> Yes, it passes testing and appears to work fine: in practice for the new 

> testcase grokdeclarator doesn't issue any further diagnostic and returns 

> error_mark_node a few lines below, around line # 11256. Shall we apply 

> this version to gcc-9-branch too?


When the branch reopens, yes.

Jason
Jakub Jelinek April 27, 2019, 9:57 p.m. | #4
On Tue, Apr 23, 2019 at 05:25:28PM +0200, Paolo Carlini wrote:
> /testsuite

> 2019-04-23  Paolo Carlini  <paolo.carlini@oracle.com>

> 

> 	PR c++/90173

> 	* g++.dg/cpp1z/class-deduction66.C: New.


The test fails everywhere if check-c++-all with:
+UNRESOLVED: g++.dg/cpp1z/class-deduction66.C  -std=c++17 compilation failed to produce executable
+UNRESOLVED: g++.dg/cpp1z/class-deduction66.C  -std=c++2a compilation failed to produce executable

Fixed thusly (the test doesn't have main and has dg-error), regtested on x86_64-linux,
committed to trunk as obvious:

2019-04-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/90173
	* g++.dg/cpp1z/class-deduction66.C: Use dg-do compile instead of
	dg-do run.

--- gcc/testsuite/g++.dg/cpp1z/class-deduction66.C.jj	2019-04-26 17:37:45.171116666 +0200
+++ gcc/testsuite/g++.dg/cpp1z/class-deduction66.C	2019-04-27 23:54:33.941071012 +0200
@@ -1,5 +1,5 @@
 // PR c++/90173
-// { dg-do run { target c++17 } }
+// { dg-do compile { target c++17 } }
 
 template <typename T> struct A { };
 

	Jakub

Patch

Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 270500)
+++ cp/decl.c	(working copy)
@@ -10973,6 +10973,7 @@  grokdeclarator (const cp_declarator *declarator,
       error_at (typespec_loc, "template placeholder type %qT must be followed "
 		"by a simple declarator-id", type);
       inform (DECL_SOURCE_LOCATION (tmpl), "%qD declared here", tmpl);
+      return error_mark_node;
     }
 
   staticp = 0;
Index: testsuite/g++.dg/cpp1z/class-deduction66.C
===================================================================
--- testsuite/g++.dg/cpp1z/class-deduction66.C	(nonexistent)
+++ testsuite/g++.dg/cpp1z/class-deduction66.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/90173
+// { dg-do run { target c++17 } }
+
+template <typename T> struct A { };
+
+A(int) -> A<int>;
+
+namespace decl {
+  A (*fp)() = 0;  // { dg-error "placeholder" }
+}