aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.dg
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2021-07-27 13:24:34 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2021-07-28 13:13:06 +0200
commit54ec50bada94a8ff92edb04ee5216c27fa4bf942 (patch)
tree41d105545a3cacb3ca44c1487c20ef03a29d640c /gcc/testsuite/gdc.dg
parentc936c39f86c74b3bfc6831f694b3165296c99dc0 (diff)
downloadgcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.zip
gcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.tar.gz
gcc-54ec50bada94a8ff92edb04ee5216c27fa4bf942.tar.bz2
d: Wrong evaluation order of binary expressions (PR101640)
The use of fold_build2 can in some cases swap the order of its operands if that is the more optimal thing to do. However this breaks semantic guarantee of left-to-right evaluation in D. PR d/101640 gcc/d/ChangeLog: * expr.cc (binary_op): Use build2 instead of fold_build2. gcc/testsuite/ChangeLog: * gdc.dg/pr96429.d: Update test. * gdc.dg/pr101640.d: New test.
Diffstat (limited to 'gcc/testsuite/gdc.dg')
-rw-r--r--gcc/testsuite/gdc.dg/pr101640.d11
-rw-r--r--gcc/testsuite/gdc.dg/pr96429.d2
2 files changed, 12 insertions, 1 deletions
diff --git a/gcc/testsuite/gdc.dg/pr101640.d b/gcc/testsuite/gdc.dg/pr101640.d
new file mode 100644
index 0000000..68de408
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr101640.d
@@ -0,0 +1,11 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101640
+// { dg-do compile }
+// { dg-options "-fdump-tree-original" }
+
+int fun101640(ref int);
+
+int test101640(int val)
+{
+ // { dg-final { scan-tree-dump "= val \\\+ fun101640 \\\(\\\(int &\\\) &val\\\);" "original" } }
+ return val + fun101640(val);
+}
diff --git a/gcc/testsuite/gdc.dg/pr96429.d b/gcc/testsuite/gdc.dg/pr96429.d
index af096e2..9940a03 100644
--- a/gcc/testsuite/gdc.dg/pr96429.d
+++ b/gcc/testsuite/gdc.dg/pr96429.d
@@ -3,7 +3,7 @@
// { dg-options "-fdump-tree-original" }
ptrdiff_t subbyte(byte* bp1, byte* bp2)
{
- // { dg-final { scan-tree-dump "bp1 - bp2;" "original" } }
+ // { dg-final { scan-tree-dump "\\\(bp1 - bp2\\\) /\\\[ex\\\] 1;" "original" } }
return bp1 - bp2;
}