From 37482edc3f7f19110da7178d0d4c3003ea5272f3 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 17 Mar 2020 19:33:14 +0100 Subject: [PATCH] d/dmd: Merge upstream dmd d1a606599 Fixes long standing regression in the D front-end implemention, and adds a new field to allow retrieving a list of all content imports from the code generator. Reviewed-on: https://github.com/dlang/dmd/pull/10913 https://github.com/dlang/dmd/pull/10933 --- gcc/d/dmd/MERGE | 2 +- gcc/d/dmd/dclass.c | 1 - gcc/d/dmd/expressionsem.c | 1 + gcc/d/dmd/module.h | 1 + .../gdc.test/compilable/imports/pr9471a.d | 2 ++ .../gdc.test/compilable/imports/pr9471b.d | 5 +++++ .../gdc.test/compilable/imports/pr9471c.d | 18 ++++++++++++++++++ .../gdc.test/compilable/imports/pr9471d.d | 1 + gcc/testsuite/gdc.test/compilable/pr9471.d | 6 ++++++ gcc/testsuite/gdc.test/runnable/traits.d | 4 ++-- 10 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gdc.test/compilable/imports/pr9471a.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/pr9471b.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/pr9471c.d create mode 100644 gcc/testsuite/gdc.test/compilable/imports/pr9471d.d create mode 100644 gcc/testsuite/gdc.test/compilable/pr9471.d diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE index 6cbc4e37819..a421448a287 100644 --- a/gcc/d/dmd/MERGE +++ b/gcc/d/dmd/MERGE @@ -1,4 +1,4 @@ -b061bd744cb4eb94a7118581387d988d4ec25e97 +d1a606599e7c2bea8fda8bf5e3ddceb486ae69ac 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/dclass.c b/gcc/d/dmd/dclass.c index bbe2f8a9d72..4609d6a9f54 100644 --- a/gcc/d/dmd/dclass.c +++ b/gcc/d/dmd/dclass.c @@ -395,7 +395,6 @@ void ClassDeclaration::semantic(Scope *sc) } else if (symtab && !scx) { - semanticRun = PASSsemanticdone; return; } semanticRun = PASSsemantic; diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c index 781bd3ea5fd..fed36cf9242 100644 --- a/gcc/d/dmd/expressionsem.c +++ b/gcc/d/dmd/expressionsem.c @@ -2370,6 +2370,7 @@ public: return setError(); } + sc->_module->contentImportedFiles.push(name); if (global.params.verbose) message("file %.*s\t(%s)", (int)se->len, (char *)se->string, name); if (global.params.moduleDeps != NULL) diff --git a/gcc/d/dmd/module.h b/gcc/d/dmd/module.h index 4a20356db89..f4253d32657 100644 --- a/gcc/d/dmd/module.h +++ b/gcc/d/dmd/module.h @@ -76,6 +76,7 @@ public: unsigned numlines; // number of lines in source file int isDocFile; // if it is a documentation input file, not D source bool isPackageFile; // if it is a package.d + Strings contentImportedFiles; // array of files whose content was imported int needmoduleinfo; int selfimports; // 0: don't know, 1: does not, 2: does diff --git a/gcc/testsuite/gdc.test/compilable/imports/pr9471a.d b/gcc/testsuite/gdc.test/compilable/imports/pr9471a.d new file mode 100644 index 00000000000..79b78e1e52a --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/pr9471a.d @@ -0,0 +1,2 @@ +import imports.pr9471c; +class AggregateDeclaration : ScopeDsymbol { } diff --git a/gcc/testsuite/gdc.test/compilable/imports/pr9471b.d b/gcc/testsuite/gdc.test/compilable/imports/pr9471b.d new file mode 100644 index 00000000000..a46a12c496f --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/pr9471b.d @@ -0,0 +1,5 @@ +import imports.pr9471a; +class ClassDeclaration : AggregateDeclaration +{ + void isBaseOf(); +} diff --git a/gcc/testsuite/gdc.test/compilable/imports/pr9471c.d b/gcc/testsuite/gdc.test/compilable/imports/pr9471c.d new file mode 100644 index 00000000000..d80a61480ce --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/pr9471c.d @@ -0,0 +1,18 @@ +import imports.pr9471b; + +struct Array(T) +{ + static if (is(typeof(T.opCmp))) { } +} +alias ClassDeclarations = Array!ClassDeclaration; + +class Dsymbol +{ + void addObjcSymbols(ClassDeclarations); +} + +class ScopeDsymbol : Dsymbol +{ + import imports.pr9471d; + void importScope(); +} diff --git a/gcc/testsuite/gdc.test/compilable/imports/pr9471d.d b/gcc/testsuite/gdc.test/compilable/imports/pr9471d.d new file mode 100644 index 00000000000..187b9083294 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/imports/pr9471d.d @@ -0,0 +1 @@ +// Module needs to be imported to trigger bug. diff --git a/gcc/testsuite/gdc.test/compilable/pr9471.d b/gcc/testsuite/gdc.test/compilable/pr9471.d new file mode 100644 index 00000000000..37ff32e4957 --- /dev/null +++ b/gcc/testsuite/gdc.test/compilable/pr9471.d @@ -0,0 +1,6 @@ +// PERMUTE_ARGS: +// EXTRA_FILES: imports/pr9471a.d imports/pr9471b.d imports/pr9471c.d imports/pr9471d.d +import imports.pr9471a; +import imports.pr9471b; + +static assert (__traits(getVirtualIndex, ClassDeclaration.isBaseOf) == 7); diff --git a/gcc/testsuite/gdc.test/runnable/traits.d b/gcc/testsuite/gdc.test/runnable/traits.d index 6c3bf7859e3..b73ee01ce42 100644 --- a/gcc/testsuite/gdc.test/runnable/traits.d +++ b/gcc/testsuite/gdc.test/runnable/traits.d @@ -1253,7 +1253,7 @@ struct S10096X this(this) {} ~this() {} - string getStr() in(str) out(r; r == str) { return str; } + string getStr() in { assert(str); } out(r) { assert(r == str); } body { return str; } } static assert( [__traits(allMembers, S10096X)] == @@ -1271,7 +1271,7 @@ class C10096X this(int) {} ~this() {} - string getStr() in(str) out(r; r == str) { return str; + string getStr() in { assert(str); } out(r) { assert(r == str); } body { return str; } } static assert( [__traits(allMembers, C10096X)] == -- 2.30.2