public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-4858] convert_to_complex vs invalid_conversion [PR111903]
@ 2023-10-23 10:55 Andrew Pinski
0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2023-10-23 10:55 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:13c0d052478bb45cc97869f5cc333f269aadb36f
commit r14-4858-g13c0d052478bb45cc97869f5cc333f269aadb36f
Author: Andrew Pinski <pinskia@gmail.com>
Date: Fri Oct 20 14:47:55 2023 -0700
convert_to_complex vs invalid_conversion [PR111903]
convert_to_complex when creating a COMPLEX_EXPR does
not currently check if either the real or imag parts
was not error_mark_node. This later on confuses the gimpilfier
when there was a SAVE_EXPR wrapped around that COMPLEX_EXPR.
The simple fix is after calling convert inside convert_to_complex_1,
check that the either result was an error_operand and return
an error_mark_node in that case.
Bootstrapped and tested on x86_64-linux-gnu with no regressions.
PR c/111903
gcc/ChangeLog:
* convert.cc (convert_to_complex_1): Return
error_mark_node if either convert was an error
when converting from a scalar.
gcc/testsuite/ChangeLog:
* gcc.target/i386/float16-8.c: New test.
Diff:
---
gcc/convert.cc | 9 +++++++--
gcc/testsuite/gcc.target/i386/float16-8.c | 12 ++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/gcc/convert.cc b/gcc/convert.cc
index 64b7001843cd..5357609d8f05 100644
--- a/gcc/convert.cc
+++ b/gcc/convert.cc
@@ -1006,8 +1006,13 @@ convert_to_complex_1 (tree type, tree expr, bool fold_p)
case ENUMERAL_TYPE:
case BOOLEAN_TYPE:
case BITINT_TYPE:
- return build2 (COMPLEX_EXPR, type, convert (subtype, expr),
- convert (subtype, integer_zero_node));
+ {
+ tree real = convert (subtype, expr);
+ tree imag = convert (subtype, integer_zero_node);
+ if (error_operand_p (real) || error_operand_p (imag))
+ return error_mark_node;
+ return build2 (COMPLEX_EXPR, type, real, imag);
+ }
case COMPLEX_TYPE:
{
diff --git a/gcc/testsuite/gcc.target/i386/float16-8.c b/gcc/testsuite/gcc.target/i386/float16-8.c
new file mode 100644
index 000000000000..003f82e71469
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/float16-8.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mno-sse" } */
+/* PR c/111903 */
+
+int i;
+_Float16 f;
+int bar(...);
+void
+foo (void)
+{
+ i /= bar ((_Complex _Float16) f); /* { dg-error "" } */
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-23 10:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-23 10:55 [gcc r14-4858] convert_to_complex vs invalid_conversion [PR111903] 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).