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

Paolo Carlini paolo.carlini@oracle.com
Tue Apr 23 15:27:00 GMT 2019


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.

///////////////////

-------------- next part --------------
/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.
-------------- next part --------------
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" }
+}


More information about the Gcc-patches mailing list