]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[c] Fix PR 101364: ICE after error due to diagnose_arglist_conflict not checking...
authorAndrew Pinski <pinskia@gmail.com>
Sat, 14 Oct 2023 20:40:05 +0000 (13:40 -0700)
committerAndrew Pinski <pinskia@gmail.com>
Wed, 18 Oct 2023 22:11:39 +0000 (15:11 -0700)
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
gcc/testsuite/gcc.dg/pr101364-1.c [new file with mode: 0644]

index 0de3847830412d44f68a815700bf75a452e34125..7a145bed281f90f3fed474d65a95b3e6ba6a8956 100644 (file)
@@ -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 (file)
index 0000000..e7c94a0
--- /dev/null
@@ -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" } */