* [PATCH] Another ICE after conflicting types of redeclaration [PR109619]
@ 2024-03-22 4:19 Andrew Pinski
2024-03-22 8:49 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2024-03-22 4:19 UTC (permalink / raw)
To: gcc-patches; +Cc: Andrew Pinski
This another one of these ICE after error issues with the
gimplifier and a fallout from r12-3278-g823685221de986af.
This case happens when we are trying to fold memcpy/memmove.
There is already code to try to catch ERROR_MARKs as arguments
to the builtins so just need to change them to use error_operand_p
which checks the type of the expression to see if it was an error mark
also.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
gcc/ChangeLog:
PR c/109619
* builtins.cc (fold_builtin_1): Use error_operand_p
instead of checking against ERROR_MARK.
(fold_builtin_2): Likewise.
(fold_builtin_3): Likewise.
gcc/testsuite/ChangeLog:
PR c/109619
* gcc.dg/redecl-26.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
gcc/builtins.cc | 12 ++++++------
gcc/testsuite/gcc.dg/redecl-26.c | 14 ++++++++++++++
2 files changed, 20 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/redecl-26.c
diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index eda8bea9c4b..bb74b5cbcd6 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -10461,7 +10461,7 @@ fold_builtin_1 (location_t loc, tree expr, tree fndecl, tree arg0)
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
- if (TREE_CODE (arg0) == ERROR_MARK)
+ if (error_operand_p (arg0))
return NULL_TREE;
if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0))
@@ -10601,8 +10601,8 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
- if (TREE_CODE (arg0) == ERROR_MARK
- || TREE_CODE (arg1) == ERROR_MARK)
+ if (error_operand_p (arg0)
+ || error_operand_p (arg1))
return NULL_TREE;
if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0, arg1))
@@ -10693,9 +10693,9 @@ fold_builtin_3 (location_t loc, tree fndecl,
tree type = TREE_TYPE (TREE_TYPE (fndecl));
enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
- if (TREE_CODE (arg0) == ERROR_MARK
- || TREE_CODE (arg1) == ERROR_MARK
- || TREE_CODE (arg2) == ERROR_MARK)
+ if (error_operand_p (arg0)
+ || error_operand_p (arg1)
+ || error_operand_p (arg2))
return NULL_TREE;
if (tree ret = fold_const_call (as_combined_fn (fcode), type,
diff --git a/gcc/testsuite/gcc.dg/redecl-26.c b/gcc/testsuite/gcc.dg/redecl-26.c
new file mode 100644
index 00000000000..5f8889c4c39
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/redecl-26.c
@@ -0,0 +1,14 @@
+/* We used to ICE while folding memcpy and memmove.
+ PR c/109619. */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+int *a1, *a2;
+
+void foo(__SIZE_TYPE__ a3) /* { dg-note "" } */
+{
+ __builtin_memcpy(a1, a2, a3);
+ __builtin_memmove(a1, a2, a3);
+ int *a3; /* { dg-error "redeclared as different kind of symbol" } */
+}
+
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Another ICE after conflicting types of redeclaration [PR109619]
2024-03-22 4:19 [PATCH] Another ICE after conflicting types of redeclaration [PR109619] Andrew Pinski
@ 2024-03-22 8:49 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-03-22 8:49 UTC (permalink / raw)
To: Andrew Pinski; +Cc: gcc-patches
On Fri, Mar 22, 2024 at 5:20 AM Andrew Pinski <quic_apinski@quicinc.com> wrote:
>
> This another one of these ICE after error issues with the
> gimplifier and a fallout from r12-3278-g823685221de986af.
> This case happens when we are trying to fold memcpy/memmove.
> There is already code to try to catch ERROR_MARKs as arguments
> to the builtins so just need to change them to use error_operand_p
> which checks the type of the expression to see if it was an error mark
> also.
>
> Bootstrapped and tested on x86_64-linux-gnu with no regressions.
OK.
> gcc/ChangeLog:
>
> PR c/109619
> * builtins.cc (fold_builtin_1): Use error_operand_p
> instead of checking against ERROR_MARK.
> (fold_builtin_2): Likewise.
> (fold_builtin_3): Likewise.
>
> gcc/testsuite/ChangeLog:
>
> PR c/109619
> * gcc.dg/redecl-26.c: New test.
>
> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
> ---
> gcc/builtins.cc | 12 ++++++------
> gcc/testsuite/gcc.dg/redecl-26.c | 14 ++++++++++++++
> 2 files changed, 20 insertions(+), 6 deletions(-)
> create mode 100644 gcc/testsuite/gcc.dg/redecl-26.c
>
> diff --git a/gcc/builtins.cc b/gcc/builtins.cc
> index eda8bea9c4b..bb74b5cbcd6 100644
> --- a/gcc/builtins.cc
> +++ b/gcc/builtins.cc
> @@ -10461,7 +10461,7 @@ fold_builtin_1 (location_t loc, tree expr, tree fndecl, tree arg0)
> tree type = TREE_TYPE (TREE_TYPE (fndecl));
> enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
>
> - if (TREE_CODE (arg0) == ERROR_MARK)
> + if (error_operand_p (arg0))
> return NULL_TREE;
>
> if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0))
> @@ -10601,8 +10601,8 @@ fold_builtin_2 (location_t loc, tree expr, tree fndecl, tree arg0, tree arg1)
> tree type = TREE_TYPE (TREE_TYPE (fndecl));
> enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
>
> - if (TREE_CODE (arg0) == ERROR_MARK
> - || TREE_CODE (arg1) == ERROR_MARK)
> + if (error_operand_p (arg0)
> + || error_operand_p (arg1))
> return NULL_TREE;
>
> if (tree ret = fold_const_call (as_combined_fn (fcode), type, arg0, arg1))
> @@ -10693,9 +10693,9 @@ fold_builtin_3 (location_t loc, tree fndecl,
> tree type = TREE_TYPE (TREE_TYPE (fndecl));
> enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
>
> - if (TREE_CODE (arg0) == ERROR_MARK
> - || TREE_CODE (arg1) == ERROR_MARK
> - || TREE_CODE (arg2) == ERROR_MARK)
> + if (error_operand_p (arg0)
> + || error_operand_p (arg1)
> + || error_operand_p (arg2))
> return NULL_TREE;
>
> if (tree ret = fold_const_call (as_combined_fn (fcode), type,
> diff --git a/gcc/testsuite/gcc.dg/redecl-26.c b/gcc/testsuite/gcc.dg/redecl-26.c
> new file mode 100644
> index 00000000000..5f8889c4c39
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/redecl-26.c
> @@ -0,0 +1,14 @@
> +/* We used to ICE while folding memcpy and memmove.
> + PR c/109619. */
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +int *a1, *a2;
> +
> +void foo(__SIZE_TYPE__ a3) /* { dg-note "" } */
> +{
> + __builtin_memcpy(a1, a2, a3);
> + __builtin_memmove(a1, a2, a3);
> + int *a3; /* { dg-error "redeclared as different kind of symbol" } */
> +}
> +
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-22 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-22 4:19 [PATCH] Another ICE after conflicting types of redeclaration [PR109619] Andrew Pinski
2024-03-22 8:49 ` Richard Biener
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).