From patchwork Fri Mar 15 13:39:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1057027 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-497960-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="QYH9wVBY"; 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 44LRXV4vs4z9s6w for ; Sat, 16 Mar 2019 00:40:08 +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=e7c0SZLVGl3a/f0lk8OXC+uwRxPsEGDfYQ7tkIBayte/38 HUs1Wsh+S8WgL0pVBoVzibYdLJWAWS4UrUrsiyze0wQO1VIZJRrW0lzYMTGM6j7D CF6tf1yhdm89pE9DETXdJkklEgXzd8JlYjbvaOmBr3cfjlbqZqZObcAhrPkMY= 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=zq1SyjfLxnUzjInR0qeb9zQxoWo=; b=QYH9wVBYLyQ/CdyA4anm v8IVY84z4sEU+DMSJ/qIItjGkDHfUjViLKi2VGwt5aj8h3qB8L6xmwoifWlAWCTi IcakPxII9z4ROm/BSOpsWtqjkAEeu1hexeotZ2ygamUUKUAH+PyxwzKC1Sd6llAk Vss5u/s27FQEUcjVsSw13xE= Received: (qmail 112431 invoked by alias); 15 Mar 2019 13:40:01 -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 112394 invoked by uid 89); 15 Mar 2019 13:40:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-16.3 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= X-HELO: mail-qk1-f169.google.com Received: from mail-qk1-f169.google.com (HELO mail-qk1-f169.google.com) (209.85.222.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Mar 2019 13:39:59 +0000 Received: by mail-qk1-f169.google.com with SMTP id z76so5474187qkb.12 for ; Fri, 15 Mar 2019 06:39:59 -0700 (PDT) MIME-Version: 1.0 From: Iain Buclaw Date: Fri, 15 Mar 2019 14:39:46 +0100 Message-ID: Subject: [PATCH, PR d/88990] Committed fix for ICE in get_symbol_decl To: gcc-patches X-IsSubscribed: yes Hi, The patch merges the D front-end implementation with dmd upstream 8d4c876c6. Backports fix where the extern storage class flag was wrongly propagated to function scope when starting the semantic pass on the body. Bootstrapped and regression tested on x86_64-linux-gnu. Committed to trunk as r269708. diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 5e4abe6f33f..230fd12db2b 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -19b1454b5ca7b1036ea5fde197d91d4a7d05c0a5 +8d4c876c658608e8f6e653803c534a9e15618f57 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/declaration.c b/gcc/d/dmd/declaration.c index 6372e39f3f6..835c6aef831 100644 --- a/gcc/d/dmd/declaration.c +++ b/gcc/d/dmd/declaration.c @@ -2008,6 +2008,7 @@ bool VarDeclaration::isDataseg() else if (storage_class & (STCstatic | STCextern | STCtls | STCgshared) || parent->isModule() || parent->isTemplateInstance() || parent->isNspace()) { + assert(!isParameter() && !isResult()); isdataseg = 1; // It is in the DataSegment } } diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c index 4b7c2233955..afba82aac7d 100644 --- a/gcc/d/dmd/func.c +++ b/gcc/d/dmd/func.c @@ -1437,7 +1437,7 @@ void FuncDeclaration::semantic3(Scope *sc) sc2->sw = NULL; sc2->fes = fes; sc2->linkage = LINKd; - sc2->stc &= ~(STCauto | STCscope | STCstatic | STCabstract | + sc2->stc &= ~(STCauto | STCscope | STCstatic | STCextern | STCabstract | STCdeprecated | STCoverride | STC_TYPECTOR | STCfinal | STCtls | STCgshared | STCref | STCreturn | STCproperty | STCnothrow | STCpure | STCsafe | STCtrusted | STCsystem); diff --git a/gcc/testsuite/gdc.test/runnable/test19734.d b/gcc/testsuite/gdc.test/runnable/test19734.d new file mode 100644 index 00000000000..efa7da3b019 --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/test19734.d @@ -0,0 +1,38 @@ +// https://issues.dlang.org/show_bug.cgi?id=19734 +// REQUIRED_ARGS: -main + +class C19734 +{ + import core.stdc.stdarg; + + extern + { + // Invalid 'this' parameter because of applied 'extern' storage class. + void testin(typeof(this) p) + in { assert(this is p); } + body + { + } + + // Undefined reference to __result. + int testout() + out { assert(__result == 2); } + body + { + return 2; + } + + // Undefined reference to var. + int testlocal() + { + int var; + return var + 2; + } + + // Variable _argptr cannot have initializer. + int testvarargs(...) + { + return 0; + } + } +} diff --git a/gcc/testsuite/gdc.test/runnable/test19735.d b/gcc/testsuite/gdc.test/runnable/test19735.d new file mode 100644 index 00000000000..8a1a5e7d871 --- /dev/null +++ b/gcc/testsuite/gdc.test/runnable/test19735.d @@ -0,0 +1,22 @@ +// https://issues.dlang.org/show_bug.cgi?id=19735 + +extern int test1(int par) +{ + int var = 42; + return var + par; +} + +extern +{ + int test2(int par) + { + int var = 42; + return var + par; + } +} + +void main() +{ + assert(test1(1) == test2(1)); +} +