aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2019-08-11 06:53:14 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2019-08-11 06:53:14 +0000
commit4c9dbb967f3948630ae9cc79283c62e01399737f (patch)
tree5aad5abb160dfa1ca76d34d25bdb39aeece848d2 /gcc
parent05ba17fd7daf3174083989947bdc1c45de5bd7b8 (diff)
downloadgcc-4c9dbb967f3948630ae9cc79283c62e01399737f.zip
gcc-4c9dbb967f3948630ae9cc79283c62e01399737f.tar.gz
gcc-4c9dbb967f3948630ae9cc79283c62e01399737f.tar.bz2
d: Fix ICE: gimplification failed (gimplify.c at 13436)
The expression that caused the ICE ++(a += 1.0); The D front-end rewrites and applies implicit type conversions so the expression gets simplified as (int)((double) a += 1.0) += 1 The codegen pass would subsequently generate the following invalid code (int)(double) a = (int)((double) a + 1.0) + 1 The LHS expression `(int)(double) a', represented as a FIX_TRUNC_EXPR being what trips as it is not a valid lvalue for assignment. While LHS casts are stripped away, convert_expr adds a double cast because it converts the expression to its original type before converting it to its target type. There is no valid reason why this is done, so it has been removed. gcc/d/ChangeLog: PR d/90601 * d-convert.cc (convert_expr): Don't convert an expression to its original front-end type before converting to its target type. gcc/testsuite/ChangeLog: PR d/90601 * gdc.dg/pr90601.d: New test. From-SVN: r274263
Diffstat (limited to 'gcc')
-rw-r--r--gcc/d/ChangeLog6
-rw-r--r--gcc/d/d-convert.cc1
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gdc.dg/pr90601.d22
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 04eaccf..5aa50a26 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,9 @@
+2019-08-11 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ PR d/90601
+ * d-convert.cc (convert_expr): Don't convert an expression to its
+ original front-end type before converting to its target type.
+
2019-08-10 Iain Buclaw <ibuclaw@gdcproject.org>
PR d/91238
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index b020eab..fd4fc3c 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -588,7 +588,6 @@ convert_expr (tree exp, Type *etype, Type *totype)
return compound_expr (exp, build_zero_cst (build_ctype (tbtype)));
}
- exp = fold_convert (build_ctype (etype), exp);
gcc_assert (TREE_CODE (exp) != STRING_CST);
break;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index adf6611..fdcb620 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-08-11 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ PR d/90601
+ * gdc.dg/pr90601.d: New test.
+
2019-08-10 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/boz_8.f90: Adjust error messages.
diff --git a/gcc/testsuite/gdc.dg/pr90601.d b/gcc/testsuite/gdc.dg/pr90601.d
new file mode 100644
index 0000000..88cdaf8c
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr90601.d
@@ -0,0 +1,22 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90601
+// { dg-do compile }
+
+int postincr(int a)
+{
+ return (a += 1.0)++;
+}
+
+int postdecr(int a)
+{
+ return (a -= 1.0)--;
+}
+
+int preincr(int a)
+{
+ return ++(a += 1.0);
+}
+
+int predecr(int a)
+{
+ return --(a -= 1.0);
+}