]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c: Fix ICE when an argument was an error mark [PR100532]
authorAndrew Pinski <pinskia@gmail.com>
Thu, 19 Oct 2023 05:42:02 +0000 (05:42 +0000)
committerAndrew Pinski <pinskia@gmail.com>
Thu, 19 Oct 2023 16:52:02 +0000 (16:52 +0000)
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.

gcc/c/c-typeck.cc
gcc/testsuite/gcc.dg/pr100532-1.c [new file with mode: 0644]

index f39dc71d59324dd9cb196cd3f05641514972e3d7..f7ce13ae738034a245105855a02046a7bd0e55cf 100644 (file)
@@ -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 (file)
index 0000000..81e37c6
--- /dev/null
@@ -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" } */
+