public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] c: [PR100532] Fix ICE when an agrgument was an error mark
@ 2023-10-19 15:38 Andrew Pinski
  2023-10-19 15:48 ` Marek Polacek
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2023-10-19 15:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

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                 | 2 +-
 gcc/testsuite/gcc.dg/pr100532-1.c | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr100532-1.c

diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 6e044b4afbc..8f8562936dc 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 00000000000..81e37c60415
--- /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" } */
+
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] c: [PR100532] Fix ICE when an agrgument was an error mark
  2023-10-19 15:38 [PATCH] c: [PR100532] Fix ICE when an agrgument was an error mark Andrew Pinski
@ 2023-10-19 15:48 ` Marek Polacek
  0 siblings, 0 replies; 2+ messages in thread
From: Marek Polacek @ 2023-10-19 15:48 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

On Thu, Oct 19, 2023 at 03:38:57PM +0000, Andrew Pinski wrote:
> 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.

Looks OK but please move [PR100532] to the end of the subject.

> 	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                 | 2 +-
>  gcc/testsuite/gcc.dg/pr100532-1.c | 7 +++++++
>  2 files changed, 8 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.dg/pr100532-1.c
> 
> diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
> index 6e044b4afbc..8f8562936dc 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 00000000000..81e37c60415
> --- /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" } */
> +

Extra newline.

Marek


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-19 15:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 15:38 [PATCH] c: [PR100532] Fix ICE when an agrgument was an error mark Andrew Pinski
2023-10-19 15:48 ` Marek Polacek

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).