From d2025512b3fb357768d85ccde8e21f571481d00f Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 15 Mar 2019 13:37:07 +0000 Subject: [PATCH] re PR d/88990 (ICE in get_symbol_decl, at d/decl.cc:1097) PR d/88990 d/dmd: Merge upstream dmd 8d4c876c6 The extern storage class flag was wrongly propagated to function scope when starting the semantic pass on the body. Fixes https://gcc.gnu.org/PR88990 Reviewed-on: https://github.com/dlang/dmd/pull/9452 From-SVN: r269708 --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/declaration.c | 1 + gcc/d/dmd/func.c | 2 +- gcc/testsuite/gdc.test/runnable/test19734.d | 38 +++++++++++++++++++++ gcc/testsuite/gdc.test/runnable/test19735.d | 22 ++++++++++++ 5 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gdc.test/runnable/test19734.d create mode 100644 gcc/testsuite/gdc.test/runnable/test19735.d 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)); +} + -- 2.30.2