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-4759] c: Fix ICE when an argument was an error mark [PR100532]
Date: Thu, 19 Oct 2023 16:51:51 +0000 (GMT)	[thread overview]
Message-ID: <20231019165151.443D13858D33@sourceware.org> (raw)

https://gcc.gnu.org/g:2454ba9e2d1ce2d1b9b2b46f6111e022364bf9b5

commit r14-4759-g2454ba9e2d1ce2d1b9b2b46f6111e022364bf9b5
Author: Andrew Pinski <pinskia@gmail.com>
Date:   Thu Oct 19 05:42:02 2023 +0000

    c: Fix ICE when an argument was an error mark [PR100532]
    
    In the case of convert_argument, we would return the same expression
    back rather than error_mark_node after the error message about
    trying to convert to an incomplete type. This causes issues in
    the gimplfier trying to see if another conversion is needed.
    
    The code here dates back to before the revision history too so
    it might be the case it never noticed we should return an error_mark_node.
    
    Bootstrapped and tested on x86_64-linux-gnu with no regressions.
    
            PR c/100532
    
    gcc/c/ChangeLog:
    
            * c-typeck.cc (convert_argument): After erroring out
            about an incomplete type return error_mark_node.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/pr100532-1.c: New test.

Diff:
---
 gcc/c/c-typeck.cc                 | 2 +-
 gcc/testsuite/gcc.dg/pr100532-1.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index f39dc71d5932..f7ce13ae7380 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -3367,7 +3367,7 @@ convert_argument (location_t ploc, tree function, tree fundecl,
     {
       error_at (ploc, "type of formal parameter %d is incomplete",
 		parmnum + 1);
-      return val;
+      return error_mark_node;
     }
 
   /* Optionally warn about conversions that differ from the default
diff --git a/gcc/testsuite/gcc.dg/pr100532-1.c b/gcc/testsuite/gcc.dg/pr100532-1.c
new file mode 100644
index 000000000000..81e37c60415c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr100532-1.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* PR c/100532 */
+
+typedef __SIZE_TYPE__ size_t;
+void *memcpy(void[], const void *, size_t); /* { dg-error "declaration of type name" } */
+void c(void) { memcpy(c, "a", 2); } /* { dg-error "type of formal parameter" } */
+

                 reply	other threads:[~2023-10-19 16:51 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=20231019165151.443D13858D33@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).