From patchwork Mon May 10 10:27:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1476305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Wjxl8s8D; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fdy1G1VkTz9sWl for ; Mon, 10 May 2021 20:27:46 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 048FE385781B; Mon, 10 May 2021 10:27:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 048FE385781B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1620642464; bh=9A+pxspzE1cHqA41rQrX+Ii2k5eHY4sFCKJlo2jrwEY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Wjxl8s8DGkbjC8XcVQk+MU5+B7CQWQh++sUnKYkG00K+gWT/wpGVyN63xh5JpjnTC KAWqySzb2QfrdH7uQnQhL3YYDTzMSRiI/3IaeMqNxJwSQEyZc9r9/5T6E8luwDR7OT RUa6jXcvTMUqmD26sIGkJDEVL4tWm9S3JhBnPoyc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by sourceware.org (Postfix) with ESMTPS id 380CF3857C4F for ; Mon, 10 May 2021 10:27:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 380CF3857C4F Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4Fdy174PFwzQjlm; Mon, 10 May 2021 12:27:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter05.heinlein-hosting.de (spamfilter05.heinlein-hosting.de [80.241.56.123]) (amavisd-new, port 10030) with ESMTP id 7ltb9jzVR4Wj; Mon, 10 May 2021 12:27:35 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Fix qualifier ignored in alias definition if parentheses are not present Date: Mon, 10 May 2021 12:27:33 +0200 Message-Id: <20210510102733.507412-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.11 / 15.00 / 15.00 X-Rspamd-Queue-Id: 5511C1810 X-Rspamd-UID: 05e4a2 X-Spam-Status: No, score=-15.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch fixes a regression where the qualifier was ignored in an alias definition if parentheses were not present. Bootstrapped and regression tested on x86_64-linux-gnu, committed to mainline and backported to releases/gcc-11. Regards, Iain. --- gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd b7d146c4c. --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/dsymbolsem.c | 7 +++++-- gcc/testsuite/gdc.test/compilable/test21898.d | 7 +++++++ 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gdc.test/compilable/test21898.d diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 86fb308d759..d29d462f42f 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -0450061c8de71328815da9323bd35c92b37d51d2 +b7d146c4c34469f876a63f26ff19091a7f9d54d7 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/dsymbolsem.c b/gcc/d/dmd/dsymbolsem.c index 33f74edf6ba..7a44ed2c41d 100644 --- a/gcc/d/dmd/dsymbolsem.c +++ b/gcc/d/dmd/dsymbolsem.c @@ -4880,8 +4880,11 @@ static void aliasInstanceSemantic(TemplateInstance *tempinst, Scope *sc, Templat TemplateTypeParameter *ttp = (*tempdecl->parameters)[0]->isTemplateTypeParameter(); Type *ta = isType(tempinst->tdtypes[0]); - Declaration *d = new AliasDeclaration(tempinst->loc, ttp->ident, ta->addMod(tempdecl->onemember->isAliasDeclaration()->type->mod)); - d->storage_class |= STCtemplateparameter; + AliasDeclaration *ad = tempdecl->onemember->isAliasDeclaration(); + + // Note: qualifiers can be in both 'ad.type.mod' and 'ad.storage_class' + Declaration *d = new AliasDeclaration(tempinst->loc, ttp->ident, ta->addMod(ad->type->mod)); + d->storage_class |= STCtemplateparameter | ad->storage_class; dsymbolSemantic(d, sc); paramscope->pop(); diff --git a/gcc/testsuite/gdc.test/compilable/test21898.d b/gcc/testsuite/gdc.test/compilable/test21898.d new file mode 100644 index 00000000000..9ac18b8cb6b --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/test21898.d @@ -0,0 +1,7 @@ +// https://issues.dlang.org/show_bug.cgi?id=21898 + +alias Works(T) = immutable(T); +alias Fails(T) = immutable T; + +static assert(is(Works!int == immutable int)); +static assert(is(Fails!int == immutable int));