From patchwork Sun Dec 2 11:48:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1006486 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-491457-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none 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="uo9eYXVA"; 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 4375xc22ynz9s8r for ; Sun, 2 Dec 2018 22:48:49 +1100 (AEDT) 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:content-type; q= dns; s=default; b=vIZbcalMAiX1XHE346WnF11Pa4q0P4vUFBS9QBBYscYkvB tnQ4JA+Pglv3QZcTJWh1UEUIkTqfISykPERPm+Hq66jXq5WEo6yS+nUykornWO8P ZDwIz+UVJyS9gnwbERe1M7UCJW4Nv8357Fim+WYsbZ1RIbp6lTi8PHaadDnX0= 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:content-type; s= default; bh=baGCITx1RMwkXwlRSTFRHhw66Vw=; b=uo9eYXVA3qTjwAcwm2q0 WUPaZcbxels8aUO6fqdI1jPQP7o7hmDmeXen2hKQodPfZpBXUEdIyUOnUzn0IjG+ PkwRD9T34k9puNN4kg8cKxUDEbXOtxNWhoh88u5gaXIhqDmgu7iP+9s/bVdpzBpK tQ7TXMCMd7I95BZwQ5Oa2Ao= Received: (qmail 81387 invoked by alias); 2 Dec 2018 11:48:42 -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 81360 invoked by uid 89); 2 Dec 2018 11:48:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=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.2 spammy=backports, Backport, MERGE, merges X-HELO: mail-qt1-f172.google.com Received: from mail-qt1-f172.google.com (HELO mail-qt1-f172.google.com) (209.85.160.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 02 Dec 2018 11:48:36 +0000 Received: by mail-qt1-f172.google.com with SMTP id y20so10768473qtm.13 for ; Sun, 02 Dec 2018 03:48:28 -0800 (PST) MIME-Version: 1.0 From: Iain Buclaw Date: Sun, 2 Dec 2018 12:48:15 +0100 Message-ID: Subject: [PATCH, d] Committed merge with upstream dmd To: gcc-patches X-IsSubscribed: yes Hi, This patch merges the D front-end implementation with dmd upstream 5220ad51e. Backports Ddoc fix that is present in upstream, but did not make its way into the C++ port of the D front-end implementation. The old special types for C long, unsigned long, and long double have also been removed as neither the compiler nor druntime bindings support handling it anymore. Commits merged from dmd. Backport Issue 14633: Fixed false DDoc warnings https://github.com/dlang/dmd/pull/9027 Remove old support code for struct __c_long/ulong/long_double https://github.com/dlang/dmd/pull/9028 Bootstrapped and tested on x86_64-linux-gnu. Committed to trunk as r266719. diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 7727205bed4..223ffbdc358 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -6243fa6d2ceab4615a9fe21c5bc9484e52bb2d1e +5220ad51eebe06754e6881d9bd5aab89dba2b065 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/cppmangle.c b/gcc/d/dmd/cppmangle.c index d2d357667cb..ad88242d820 100644 --- a/gcc/d/dmd/cppmangle.c +++ b/gcc/d/dmd/cppmangle.c @@ -952,15 +952,6 @@ public: if (t->isImmutable() || t->isShared()) return error(t); - /* __c_long and __c_ulong get special mangling - */ - Identifier *id = t->sym->ident; - //printf("struct id = '%s'\n", id->toChars()); - if (id == Id::__c_long) - return writeBasicType(t, 0, 'l'); - else if (id == Id::__c_ulong) - return writeBasicType(t, 0, 'm'); - //printf("TypeStruct %s\n", t->toChars()); doSymbol(t); } diff --git a/gcc/d/dmd/doc.c b/gcc/d/dmd/doc.c index d35ca7b2522..797991ee2c4 100644 --- a/gcc/d/dmd/doc.c +++ b/gcc/d/dmd/doc.c @@ -133,6 +133,25 @@ bool isCVariadicParameter(Dsymbols *a, const utf8_t *p, size_t len) return false; } +/**************************************************** + */ +static Parameter *isFunctionParameter(Dsymbol *s, const utf8_t *p, size_t len) +{ + TypeFunction *tf = isTypeFunction(s); + if (tf && tf->parameters) + { + for (size_t k = 0; k < tf->parameters->dim; k++) + { + Parameter *fparam = (*tf->parameters)[k]; + if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0) + { + return fparam; + } + } + } + return NULL; +} + static Dsymbol *getEponymousMember(TemplateDeclaration *td) { if (!td->onemember) @@ -150,6 +169,54 @@ static Dsymbol *getEponymousMember(TemplateDeclaration *td) return NULL; } +/**************************************************** + */ +static Parameter *isEponymousFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len) +{ + for (size_t i = 0; i < a->dim; i++) + { + TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration(); + if (td && td->onemember) + { + /* Case 1: we refer to a template declaration inside the template + + /// ...ddoc... + template case1(T) { + void case1(R)() {} + } + */ + td = td->onemember->isTemplateDeclaration(); + } + if (!td) + { + /* Case 2: we're an alias to a template declaration + + /// ...ddoc... + alias case2 = case1!int; + */ + AliasDeclaration *ad = (*a)[i]->isAliasDeclaration(); + if (ad && ad->aliassym) + { + td = ad->aliassym->isTemplateDeclaration(); + } + } + while (td) + { + Dsymbol *sym = getEponymousMember(td); + if (sym) + { + Parameter *fparam = isFunctionParameter(sym, p, len); + if (fparam) + { + return fparam; + } + } + td = td->overnext; + } + } + return NULL; +} + static TemplateDeclaration *getEponymousParent(Dsymbol *s) { if (!s->parent) @@ -1590,6 +1657,12 @@ void ParamSection::write(Loc loc, DocComment *, Scope *sc, Dsymbols *a, OutBuffe { size_t o = buf->offset; Parameter *fparam = isFunctionParameter(a, namestart, namelen); + if (!fparam) + { + // Comments on a template might refer to function parameters within. + // Search the parameters of nested eponymous functions (with the same name.) + fparam = isEponymousFunctionParameter(a, namestart, namelen); + } bool isCVariadic = isCVariadicParameter(a, namestart, namelen); if (isCVariadic) { @@ -2085,17 +2158,10 @@ Parameter *isFunctionParameter(Dsymbols *a, const utf8_t *p, size_t len) { for (size_t i = 0; i < a->dim; i++) { - TypeFunction *tf = isTypeFunction((*a)[i]); - if (tf && tf->parameters) + Parameter *fparam = isFunctionParameter((*a)[i], p, len); + if (fparam) { - for (size_t k = 0; k < tf->parameters->dim; k++) - { - Parameter *fparam = (*tf->parameters)[k]; - if (fparam->ident && cmp(fparam->ident->toChars(), p, len) == 0) - { - return fparam; - } - } + return fparam; } } return NULL; @@ -2108,7 +2174,10 @@ TemplateParameter *isTemplateParameter(Dsymbols *a, const utf8_t *p, size_t len) { for (size_t i = 0; i < a->dim; i++) { - TemplateDeclaration *td = getEponymousParent((*a)[i]); + TemplateDeclaration *td = (*a)[i]->isTemplateDeclaration(); + // Check for the parent, if the current symbol is not a template declaration. + if (!td) + td = getEponymousParent((*a)[i]); if (td && td->origParameters) { for (size_t k = 0; k < td->origParameters->dim; k++) diff --git a/gcc/testsuite/gdc.test/compilable/ddoc10236.d b/gcc/testsuite/gdc.test/compilable/ddoc10236.d index 25738ec34e3..1c547613c44 100644 --- a/gcc/testsuite/gdc.test/compilable/ddoc10236.d +++ b/gcc/testsuite/gdc.test/compilable/ddoc10236.d @@ -1,5 +1,5 @@ // PERMUTE_ARGS: -// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o- +// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- /* TEST_OUTPUT: diff --git a/gcc/testsuite/gdc.test/compilable/ddoc10236b.d b/gcc/testsuite/gdc.test/compilable/ddoc10236b.d index d814d375c06..065ced0936c 100644 --- a/gcc/testsuite/gdc.test/compilable/ddoc10236b.d +++ b/gcc/testsuite/gdc.test/compilable/ddoc10236b.d @@ -1,5 +1,5 @@ // PERMUTE_ARGS: -// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o- +// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- /* TEST_OUTPUT: diff --git a/gcc/testsuite/gdc.test/compilable/ddoc13502.d b/gcc/testsuite/gdc.test/compilable/ddoc13502.d index 6ab2ca0614d..93f383fea9f 100644 --- a/gcc/testsuite/gdc.test/compilable/ddoc13502.d +++ b/gcc/testsuite/gdc.test/compilable/ddoc13502.d @@ -1,5 +1,5 @@ // PERMUTE_ARGS: -// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o- +// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- /* TEST_OUTPUT: --- diff --git a/gcc/testsuite/gdc.test/compilable/ddoc4899.d b/gcc/testsuite/gdc.test/compilable/ddoc4899.d index 1fbd6a9cbe8..b5cfa86367c 100644 --- a/gcc/testsuite/gdc.test/compilable/ddoc4899.d +++ b/gcc/testsuite/gdc.test/compilable/ddoc4899.d @@ -1,5 +1,5 @@ // PERMUTE_ARGS: -// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -w -o- +// REQUIRED_ARGS: -D -Dd${RESULTS_DIR}/compilable -wi -o- /* TEST_OUTPUT: diff --git a/gcc/testsuite/gdc.test/runnable/cppa.d b/gcc/testsuite/gdc.test/runnable/cppa.d index 3b283427951..82b93adf1f6 100644 --- a/gcc/testsuite/gdc.test/runnable/cppa.d +++ b/gcc/testsuite/gdc.test/runnable/cppa.d @@ -612,13 +612,7 @@ extern(C++) version (CRuntime_Microsoft) { - struct __c_long_double - { - this(double d) { ld = d; } - double ld; - alias ld this; - } - + enum __c_long_double : double; alias __c_long_double myld; } else @@ -655,20 +649,8 @@ else } } -struct __c_long -{ - this(x_long d) { ld = d; } - x_long ld; - alias ld this; -} - -struct __c_ulong -{ - this(x_ulong d) { ld = d; } - x_ulong ld; - alias ld this; -} - +enum __c_long : x_long; +enum __c_ulong : x_ulong; alias __c_long mylong; alias __c_ulong myulong; @@ -688,6 +670,43 @@ void test16() ld = testul(ld); assert(ld == 5 + myulong.sizeof); } + + static if (__c_long.sizeof == long.sizeof) + { + static assert(__c_long.max == long.max); + static assert(__c_long.min == long.min); + static assert(__c_long.init == long.init); + static assert(__c_ulong.max == ulong.max); + static assert(__c_ulong.min == ulong.min); + static assert(__c_ulong.init == ulong.init); + __c_long cl = 0; + cl = cl + 1; + long l = cl; + cl = l; + __c_ulong cul = 0; + cul = cul + 1; + ulong ul = cul; + cul = ul; + } + else static if (__c_long.sizeof == int.sizeof) + { + static assert(__c_long.max == int.max); + static assert(__c_long.min == int.min); + static assert(__c_long.init == int.init); + static assert(__c_ulong.max == uint.max); + static assert(__c_ulong.min == uint.min); + static assert(__c_ulong.init == uint.init); + __c_long cl = 0; + cl = cl + 1; + int i = cl; + cl = i; + __c_ulong cul = 0; + cul = cul + 1; + uint u = cul; + cul = u; + } + else + static assert(0); } /****************************************/