diff mbox series

[2/2,c] Fix PR 101364: ICE after error due to diagnose_arglist_conflict not checking for error

Message ID 20231015011648.1608638-2-pinskia@gmail.com
State New
Headers show
Series [1/2] Fix ICE due to c_safe_arg_type_equiv_p not checking for error_mark node | expand

Commit Message

Andrew Pinski Oct. 15, 2023, 1:16 a.m. UTC
When checking to see if we have a function declaration has a conflict due to
promotations, there is no test to see if the type was an error mark and then calls
c_type_promotes_to. c_type_promotes_to is not ready for error_mark and causes an
ICE.

This adds a check for error before the call of c_type_promotes_to.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR c/101364

gcc/c/ChangeLog:

	* c-decl.cc (diagnose_arglist_conflict): Test for
	error mark before calling of c_type_promotes_to.

gcc/testsuite/ChangeLog:

	* gcc.dg/pr101364-1.c: New test.
---
 gcc/c/c-decl.cc                   | 3 ++-
 gcc/testsuite/gcc.dg/pr101364-1.c | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr101364-1.c

Comments

Joseph Myers Oct. 16, 2023, 9:38 p.m. UTC | #1
On Sat, 14 Oct 2023, Andrew Pinski wrote:

> When checking to see if we have a function declaration has a conflict due to
> promotations, there is no test to see if the type was an error mark and then calls
> c_type_promotes_to. c_type_promotes_to is not ready for error_mark and causes an
> ICE.
> 
> This adds a check for error before the call of c_type_promotes_to.
> 
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

OK.
diff mbox series

Patch

diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 5822faf01b4..eb2df08c0a7 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -1899,7 +1899,8 @@  diagnose_arglist_conflict (tree newdecl, tree olddecl,
 	  break;
 	}
 
-      if (c_type_promotes_to (type) != type)
+      if (!error_operand_p (type)
+	  && c_type_promotes_to (type) != type)
 	{
 	  inform (input_location, "an argument type that has a default "
 		  "promotion cannot match an empty parameter name list "
diff --git a/gcc/testsuite/gcc.dg/pr101364-1.c b/gcc/testsuite/gcc.dg/pr101364-1.c
new file mode 100644
index 00000000000..e7c94a05553
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr101364-1.c
@@ -0,0 +1,8 @@ 
+/* { dg-do compile } */
+/* { dg-options "-std=c90 "} */
+
+void fruit(); /* { dg-message "previous declaration" } */
+void fruit( /* { dg-error "conflicting types for" } */
+    int b[x], /* { dg-error "undeclared " } */
+    short c)
+{} /* { dg-message "an argument type that has a" } */