* [PATCH] Another ICE after conflicting types of redeclaration [PR110682]
@ 2024-03-23 5:50 Andrew Pinski
2024-04-08 23:55 ` Andrew Pinski (QUIC)
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Pinski @ 2024-03-23 5:50 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.
The problem here is that STRIP_USELESS_TYPE_CONVERSION will
leave around a NON_LVALUE_EXPR which is an error mark node.
Since the gimplifier assumes non-lvalue expressions has been
removed, there was an ICE.
This fixes the issue by checking if there is a NON_LVALUE_EXPR
and that has an error operand, we handle it as the same as if
it was an error operand.
gcc/ChangeLog:
PR c/110682
* gimplify.cc (gimplify_expr): Add check if there is
a non-lvalue with an error operand.
gcc/testsuite/ChangeLog:
PR c/110682
* gcc.dg/redecl-27.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
gcc/gimplify.cc | 6 +++++-
gcc/testsuite/gcc.dg/redecl-27.c | 14 ++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/redecl-27.c
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index d64bbf3ffbd..001b4af68b9 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -17686,7 +17686,11 @@ gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
save_expr = *expr_p;
/* Die, die, die, my darling. */
- if (error_operand_p (save_expr))
+ if (error_operand_p (save_expr)
+ /* The above strip useless type conversion might not strip out
+ a conversion from an error so handle that case here. */
+ || (TREE_CODE (save_expr) == NON_LVALUE_EXPR
+ && error_operand_p (TREE_OPERAND (save_expr, 0))))
{
ret = GS_ERROR;
break;
diff --git a/gcc/testsuite/gcc.dg/redecl-27.c b/gcc/testsuite/gcc.dg/redecl-27.c
new file mode 100644
index 00000000000..93f577e64ff
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/redecl-27.c
@@ -0,0 +1,14 @@
+/* We used to ICE while gimplifying the body of f
+ due to a NON_LVALUE_EXPR still being there.
+ PR c/110682*/
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+struct a {
+ const signed char b;
+};
+
+void f(volatile struct a *c) { /* { dg-note "" } */
+ c - 0 % c->b;
+ struct a c = {1}; /* { 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 [PR110682]
2024-03-23 5:50 [PATCH] Another ICE after conflicting types of redeclaration [PR110682] Andrew Pinski
@ 2024-04-08 23:55 ` Andrew Pinski (QUIC)
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Pinski (QUIC) @ 2024-04-08 23:55 UTC (permalink / raw)
To: Andrew Pinski (QUIC), gcc-patches
> -----Original Message-----
> From: Andrew Pinski (QUIC) <quic_apinski@quicinc.com>
> Sent: Friday, March 22, 2024 10:50 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Andrew Pinski (QUIC) <quic_apinski@quicinc.com>
> Subject: [PATCH] Another ICE after conflicting types of redeclaration
> [PR110682]
>
> This another one of these ICE after error issues with the gimplifier and a fallout
> from r12-3278-g823685221de986af.
> The problem here is that STRIP_USELESS_TYPE_CONVERSION will leave
> around a NON_LVALUE_EXPR which is an error mark node.
> Since the gimplifier assumes non-lvalue expressions has been removed, there
> was an ICE.
>
> This fixes the issue by checking if there is a NON_LVALUE_EXPR and that has an
> error operand, we handle it as the same as if it was an error operand.
Ping?
Thanks,
Andrew
>
> gcc/ChangeLog:
>
> PR c/110682
> * gimplify.cc (gimplify_expr): Add check if there is
> a non-lvalue with an error operand.
>
> gcc/testsuite/ChangeLog:
>
> PR c/110682
> * gcc.dg/redecl-27.c: New test.
>
> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
> ---
> gcc/gimplify.cc | 6 +++++-
> gcc/testsuite/gcc.dg/redecl-27.c | 14 ++++++++++++++
> 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644
> gcc/testsuite/gcc.dg/redecl-27.c
>
> diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index d64bbf3ffbd..001b4af68b9
> 100644
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -17686,7 +17686,11 @@ gimplify_expr (tree *expr_p, gimple_seq
> *pre_p, gimple_seq *post_p,
> save_expr = *expr_p;
>
> /* Die, die, die, my darling. */
> - if (error_operand_p (save_expr))
> + if (error_operand_p (save_expr)
> + /* The above strip useless type conversion might not strip out
> + a conversion from an error so handle that case here. */
> + || (TREE_CODE (save_expr) == NON_LVALUE_EXPR
> + && error_operand_p (TREE_OPERAND (save_expr, 0))))
> {
> ret = GS_ERROR;
> break;
> diff --git a/gcc/testsuite/gcc.dg/redecl-27.c b/gcc/testsuite/gcc.dg/redecl-
> 27.c
> new file mode 100644
> index 00000000000..93f577e64ff
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/redecl-27.c
> @@ -0,0 +1,14 @@
> +/* We used to ICE while gimplifying the body of f
> + due to a NON_LVALUE_EXPR still being there.
> + PR c/110682*/
> +/* { dg-do compile } */
> +/* { dg-options "" } */
> +
> +struct a {
> + const signed char b;
> +};
> +
> +void f(volatile struct a *c) { /* { dg-note "" } */
> + c - 0 % c->b;
> + struct a c = {1}; /* { 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-04-08 23:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-23 5:50 [PATCH] Another ICE after conflicting types of redeclaration [PR110682] Andrew Pinski
2024-04-08 23:55 ` Andrew Pinski (QUIC)
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).