public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4728] [c] Fix PR 101364: ICE after error due to diagnose_arglist_conflict not checking for error
Date: Wed, 18 Oct 2023 22:35:09 +0000 (GMT)	[thread overview]
Message-ID: <20231018223509.AC4A63857C5A@sourceware.org> (raw)

https://gcc.gnu.org/g:879c91fcccf93681bd7e13290bfbb384cadcd268

commit r14-4728-g879c91fcccf93681bd7e13290bfbb384cadcd268
Author: Andrew Pinski <pinskia@gmail.com>
Date:   Sat Oct 14 13:40:05 2023 -0700

    [c] Fix PR 101364: ICE after error due to diagnose_arglist_conflict not checking for error
    
    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.

Diff:
---
 gcc/c/c-decl.cc                   | 3 ++-
 gcc/testsuite/gcc.dg/pr101364-1.c | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 0de384783041..7a145bed281f 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 000000000000..e7c94a05553c
--- /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" } */

                 reply	other threads:[~2023-10-18 22:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231018223509.AC4A63857C5A@sourceware.org \
    --to=pinskia@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).