public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] PR c/104506: Tolerate error_mark_node in useless_type_conversion_p.
@ 2022-02-14 12:54 Roger Sayle
  2022-02-14 15:31 ` Richard Biener
  2022-02-14 23:57 ` Andrew Pinski
  0 siblings, 2 replies; 7+ messages in thread
From: Roger Sayle @ 2022-02-14 12:54 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 930 bytes --]

 

This simple fix to the middle-end, resolves PR c/104506, by adding an

explicit check for error_mark_node to useless_type_conversion_p.  I first

trying fixing this in the C front-end, but the type is valid at the point

that the NOP_EXPR is created, so the poisoned type leaks to the middle-end.

Returning either true or false from useless_type_conversion_p avoids the

ICE-after-error.  Apologies to Andrew Pinski, I hadn't noticed that he'd

assigned this PR to himself until after my regression testing had finished.

 

This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and

make -k check with no new failures.  Ok for mainline?

 

 

2022-02-14  Roger Sayle  <roger@nextmovesoftware.com>

 

gcc/ChangeLog

PR c/104506

* gimple-expr.cc (useless_type_conversion_p): Add a check for

error_mark_node.

 

gcc/testsuite/ChangeLog

PR c/104506

* gcc.dg/pr104506.c: New test case.

 

 

Roger

--

 


[-- Attachment #2: patchckb.txt --]
[-- Type: text/plain, Size: 929 bytes --]

diff --git a/gcc/gimple-expr.cc b/gcc/gimple-expr.cc
index f9a650b..e63fa3c 100644
--- a/gcc/gimple-expr.cc
+++ b/gcc/gimple-expr.cc
@@ -83,6 +83,9 @@ useless_type_conversion_p (tree outer_type, tree inner_type)
 	return false;
     }
 
+  if (inner_type == error_mark_node)
+    return true;
+
   /* From now on qualifiers on value types do not matter.  */
   inner_type = TYPE_MAIN_VARIANT (inner_type);
   outer_type = TYPE_MAIN_VARIANT (outer_type);
diff --git a/gcc/testsuite/gcc.dg/pr104506.c b/gcc/testsuite/gcc.dg/pr104506.c
new file mode 100644
index 0000000..79cec1a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr104506.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+double x;
+/* { dg-message "note: previous declaration" "previous declaration" { target *-*
+ * -* } .-1 } */
+
+void foo (void)
+{
+  x;
+}
+
+int x;  /* { dg-error "conflicting types" } */
+

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

end of thread, other threads:[~2022-02-18 21:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-14 12:54 [PATCH] PR c/104506: Tolerate error_mark_node in useless_type_conversion_p Roger Sayle
2022-02-14 15:31 ` Richard Biener
2022-02-14 15:34   ` Richard Biener
2022-02-14 23:57 ` Andrew Pinski
2022-02-15  7:32   ` Richard Biener
2022-02-15  7:39     ` Andrew Pinski
2022-02-18 21:41       ` Andrew Pinski

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