PATCH to fix ICE-on-invalid with -Wabi (PR c++/83490)

Message ID 20171219145033.GP2605@redhat.com
State New
Headers show
Series
  • PATCH to fix ICE-on-invalid with -Wabi (PR c++/83490)
Related show

Commit Message

Marek Polacek Dec. 19, 2017, 2:50 p.m.
This is an ICE-on-invalid where the code in init_cumulative_args tries to
determine if it should warn about the empty classes ABI change, but is upset
when it encounters error_mark_node.  Thus fixed.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2017-12-19  Marek Polacek  <polacek@redhat.com>

	PR c++/83490
	* config/i386/i386.c (init_cumulative_args): Don't check TYPE_EMPTY_P
	on an error node.						     

	* g++.dg/abi/pr83490.C: New test.


	Marek

Comments

Jakub Jelinek Dec. 19, 2017, 2:54 p.m. | #1
On Tue, Dec 19, 2017 at 03:50:33PM +0100, Marek Polacek wrote:
> This is an ICE-on-invalid where the code in init_cumulative_args tries to

> determine if it should warn about the empty classes ABI change, but is upset

> when it encounters error_mark_node.  Thus fixed.

> 

> Bootstrapped/regtested on x86_64-linux, ok for trunk?

> 

> 2017-12-19  Marek Polacek  <polacek@redhat.com>

> 

> 	PR c++/83490

> 	* config/i386/i386.c (init_cumulative_args): Don't check TYPE_EMPTY_P

> 	on an error node.						     

> 

> 	* g++.dg/abi/pr83490.C: New test.


Ok, thanks.

	Jakub

Patch

diff --git gcc/config/i386/i386.c gcc/config/i386/i386.c
index b9f6e27f9b1..82a79bdb426 100644
--- gcc/config/i386/i386.c
+++ gcc/config/i386/i386.c
@@ -7218,7 +7218,7 @@  init_cumulative_args (CUMULATIVE_ARGS *cum,  /* Argument info to initialize */
       bool seen_empty_type = false;
       FOREACH_FUNCTION_ARGS (fntype, argtype, iter)
 	{
-	  if (VOID_TYPE_P (argtype))
+	  if (argtype == error_mark_node || VOID_TYPE_P (argtype))
 	    break;
 	  if (TYPE_EMPTY_P (argtype))
 	    seen_empty_type = true;
diff --git gcc/testsuite/g++.dg/abi/pr83490.C gcc/testsuite/g++.dg/abi/pr83490.C
index e69de29bb2d..850c4c0fd9e 100644
--- gcc/testsuite/g++.dg/abi/pr83490.C
+++ gcc/testsuite/g++.dg/abi/pr83490.C
@@ -0,0 +1,17 @@ 
+// PR c++/83490
+// { dg-options "-Wabi" }
+
+struct A
+{
+  A foo(void i = 0);  // { dg-error "incomplete type|invalid use" }
+};
+
+void bar()
+{
+  A().foo();
+}
+
+A A::foo(void i)  // { dg-error "incomplete type|invalid use" }
+{
+  return A();
+}