From patchwork Sun Apr 21 20:27:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1088539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-499525-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=gdcproject.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="kKDjKSvy"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44nLqY4mCMz9s3q for ; Mon, 22 Apr 2019 06:27:34 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; q=dns; s=default; b=wibABkirNbCNLeZTldhlVTpQ01STfCE6Fn+X2JlvXg5 S8dgN8Zitl+wTl9xfrgOLY17//GRXDtPDnvgpNeZQUD23tBoQHABQRbnRX5Yxpsk RyyqrRajvUSg5fcuOFpzhs1RmdoTHG3FpbdjA++WI+ocg9R4GrWcw8GjIB5lypUI = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:cc:content-type; s=default; bh=SpbVMiyCSMsGgKMkls3Z13dDHn8=; b=kKDjKSvyigrUjMPBo aL29mUtmqu8lEMsEOa2wn1KFWK99oF2bPf2q00W2zgcfYWeaqE3CzWSdGCAGRuuo zsmmjW0RZRlR9ii8PQFeRi2sRcm66g5hIeU07jRM2bQ9N6Ohm0JvtkUS90cZ7PuN HTcaUeY9X3wmK20o00whpNMHTc= Received: (qmail 72519 invoked by alias); 21 Apr 2019 20:27:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 72498 invoked by uid 89); 21 Apr 2019 20:27:25 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=UD:b, prepend, bigendian, H*Ad:D*ibm.com X-HELO: mail-qk1-f179.google.com Received: from mail-qk1-f179.google.com (HELO mail-qk1-f179.google.com) (209.85.222.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 21 Apr 2019 20:27:24 +0000 Received: by mail-qk1-f179.google.com with SMTP id c1so5451188qkk.4 for ; Sun, 21 Apr 2019 13:27:24 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Sun, 21 Apr 2019 22:27:11 +0200 Message-ID: Subject: [PATCH, PR d/90130] Committed dmd fixes for big endian targets To: gcc-patches Cc: Robin Dapp X-IsSubscribed: yes Hi, This patch merges the D front-end implementation with dmd upstream 065fbd452. Fixes one endian bug in CTFE, and corrects tests in the D2 testsuite that failed on big endian targets. Boostrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r270485. diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index be0c5a50da2..c360fe5c2ed 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 ddd356bb966..ed3e7491983 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 1f4e55d9ac4..91d93dbf81e 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 7656de70af6..2b1fb0e62f7 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 ee17be0b00f..f43f6a46091 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); } /*******************************************/