aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gcc.gnu.org>2019-04-21 20:26:12 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2019-04-21 20:26:12 +0000
commit3595df34b5a39efb5eb56ecb1439d8dd8458a587 (patch)
treeb99cfbb7070c222a9e0d179244991d1cb7441d0d
parentf94302e90b09bc30d5ba357d4f84aa37f7a75ad1 (diff)
downloadgcc-3595df34b5a39efb5eb56ecb1439d8dd8458a587.zip
gcc-3595df34b5a39efb5eb56ecb1439d8dd8458a587.tar.gz
gcc-3595df34b5a39efb5eb56ecb1439d8dd8458a587.tar.bz2
re PR d/90130 (gdc.test/runnable/test12.d FAILs)
PR d/90130 d/dmd: Merge upstream dmd 065fbd452 Fixes endian bug in CTFE, and corrects tests in the D2 testsuite that failed on big endian targets. Initial patch by Robin Dapp. Reviewed-on: https://github.com/dlang/dmd/pull/9665 From-SVN: r270485
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/constfold.c6
-rw-r--r--gcc/testsuite/gdc.test/runnable/mars1.d6
-rw-r--r--gcc/testsuite/gdc.test/runnable/test12.d9
-rw-r--r--gcc/testsuite/gdc.test/runnable/test23.d29
5 files changed, 30 insertions, 22 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index be0c5a5..c360fe5 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-c185f9df1789456c7d88d047f2df23dd784f1182
+065fbd452f2aa498fc3a554be48a5495bd98aa14
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/constfold.c b/gcc/d/dmd/constfold.c
index ddd356b..ed3e749 100644
--- a/gcc/d/dmd/constfold.c
+++ b/gcc/d/dmd/constfold.c
@@ -1752,14 +1752,16 @@ UnionExp Cat(Type *type, Expression *e1, Expression *e2)
}
else if (e1->op == TOKint64 && e2->op == TOKstring)
{
- // Concatenate the strings
+ // [w|d]?char ~ string --> string
+ // We assume that we only ever prepend one char of the same type
+ // (wchar,dchar) as the string's characters.
StringExp *es2 = (StringExp *)e2;
size_t len = 1 + es2->len;
unsigned char sz = es2->sz;
dinteger_t v = e1->toInteger();
void *s = mem.xmalloc((len + 1) * sz);
- memcpy((char *)s, &v, sz);
+ Port::valcpy((char *)s, v, sz);
memcpy((char *)s + sz, es2->string, es2->len * sz);
// Add terminating 0
diff --git a/gcc/testsuite/gdc.test/runnable/mars1.d b/gcc/testsuite/gdc.test/runnable/mars1.d
index 1f4e55d..91d93db 100644
--- a/gcc/testsuite/gdc.test/runnable/mars1.d
+++ b/gcc/testsuite/gdc.test/runnable/mars1.d
@@ -238,13 +238,13 @@ void test13023(ulong n)
struct U { int a; union { char c; int d; } long b; }
-U f = { b:3, d:2, a:1 };
+U f = { b:3, d:0x22222222, a:1 };
void testU()
{
assert(f.b == 3);
- assert(f.d == 2);
- assert(f.c == 2);
+ assert(f.d == 0x22222222);
+ assert(f.c == 0x22);
assert(f.a == 1);
assert(f.sizeof == 16);
assert(U.sizeof == 16);
diff --git a/gcc/testsuite/gdc.test/runnable/test12.d b/gcc/testsuite/gdc.test/runnable/test12.d
index 7656de7..2b1fb0e 100644
--- a/gcc/testsuite/gdc.test/runnable/test12.d
+++ b/gcc/testsuite/gdc.test/runnable/test12.d
@@ -622,9 +622,12 @@ struct S29 {
int hoge(S29 s) {
char[10] b;
- printf("%x\n", s);
- sprintf(b.ptr, "%x", s);
- assert(b[0 .. 7] == "4030201");
+ printf("%x\n", *cast(int*)&s);
+ sprintf(b.ptr, "%x", *cast(int*)&s);
+ version (LittleEndian)
+ assert(b[0 .. 7] == "4030201");
+ version (BigEndian)
+ assert(b[0 .. 7] == "1020304");
return 0;
}
diff --git a/gcc/testsuite/gdc.test/runnable/test23.d b/gcc/testsuite/gdc.test/runnable/test23.d
index ee17be0..f43f6a4 100644
--- a/gcc/testsuite/gdc.test/runnable/test23.d
+++ b/gcc/testsuite/gdc.test/runnable/test23.d
@@ -553,19 +553,22 @@ void test24()
void test25()
{
- char[6] cstr = "123456"c;
- auto str1 = cast(wchar[3])(cstr);
-
- writefln("str1: ", (cast(char[])str1).length , " : ", (cast(char[])str1));
- assert(cast(char[])str1 == "123456"c);
-
- auto str2 = cast(wchar[3])("789abc"c);
- writefln("str2: ", (cast(char[])str2).length , " : ", (cast(char[])str2));
- assert(cast(char[])str2 == "789abc"c);
-
- auto str3 = cast(wchar[3])("defghi");
- writefln("str3: ", (cast(char[])str3).length , " : ", (cast(char[])str3));
- assert(cast(char[])str3 == "d\000e\000f\000"c);
+ char[6] cstr = "123456"c;
+ auto str1 = cast(wchar[3])(cstr);
+
+ writefln("str1: ", (cast(char[])str1).length , " : ", (cast(char[])str1));
+ assert(cast(char[])str1 == "123456"c);
+
+ auto str2 = cast(wchar[3])("789abc"c);
+ writefln("str2: ", (cast(char[])str2).length , " : ", (cast(char[])str2));
+ assert(cast(char[])str2 == "789abc"c);
+
+ auto str3 = cast(wchar[3])("defghi");
+ writefln("str3: ", (cast(char[])str3).length , " : ", (cast(char[])str3));
+ version (LittleEndian)
+ assert(cast(char[])str3 == "d\000e\000f\000"c);
+ version (BigEndian)
+ assert(cast(char[])str3 == "\000d\000e\000f"c);
}
/*******************************************/