d: Merge upstream dmd 70aabfb51
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 11 Oct 2020 20:20:43 +0000 (22:20 +0200)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 12 Oct 2020 10:14:47 +0000 (12:14 +0200)
Fixes a symbol resolver bug where a private alias becomes public if used
before its declaration.

Reviewed-on: https://github.com/dlang/dmd/pull/11831

gcc/d/ChangeLog:

* dmd/MERGE: Merge upstream dmd 70aabfb51

gcc/d/dmd/MERGE
gcc/d/dmd/declaration.c
gcc/testsuite/gdc.test/fail_compilation/fail21001.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/fail21001b.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/issue21295ast_node.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/issue21295astcodegen.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/issue21295dtemplate.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/imports/issue21295visitor.d [new file with mode: 0644]
gcc/testsuite/gdc.test/fail_compilation/issue21295.d [new file with mode: 0644]

index 8a59cbde78e95b0b0e094a5ab7a5436827650a26..5f6193f76b7a2dee74a2d5cb8c7d733b4fb1a788 100644 (file)
@@ -1,4 +1,4 @@
-3a979052509fff8170ba80e48817377a60e78eb3
+70aabfb511d55f2bfbdccbac7868519d9d4b63da
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/dmd repository.
index 08b295070b229582ec146035ba33bd515f95a721..f490cc5a4135c6f5dd43473227888aa01a8d4ff2 100644 (file)
@@ -340,6 +340,13 @@ void AliasDeclaration::semantic(Scope *sc)
 void AliasDeclaration::aliasSemantic(Scope *sc)
 {
     //printf("AliasDeclaration::semantic() %s\n", toChars());
+
+    // as AliasDeclaration::semantic, in case we're called first.
+    // see https://issues.dlang.org/show_bug.cgi?id=21001
+    storage_class |= sc->stc & STCdeprecated;
+    protection = sc->protection;
+    userAttribDecl = sc->userAttribDecl;
+
     // TypeTraits needs to know if it's located in an AliasDeclaration
     sc->flags |= SCOPEalias;
 
diff --git a/gcc/testsuite/gdc.test/fail_compilation/fail21001.d b/gcc/testsuite/gdc.test/fail_compilation/fail21001.d
new file mode 100644 (file)
index 0000000..0faeb40
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/fail21001.d(12): Error: undefined identifier `Alias`
+---
+*/
+
+module fail21001;
+
+import imports.fail21001b;
+
+void main() { Alias var; }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/fail21001b.d b/gcc/testsuite/gdc.test/fail_compilation/imports/fail21001b.d
new file mode 100644 (file)
index 0000000..69c1c20
--- /dev/null
@@ -0,0 +1,5 @@
+module imports.fail21001b;
+
+private struct S { Alias member; }
+
+private alias Alias = int;
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295ast_node.d b/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295ast_node.d
new file mode 100644 (file)
index 0000000..d9298bf
--- /dev/null
@@ -0,0 +1,5 @@
+module imports.issue21295ast_node;
+import imports.issue21295visitor : Visitor;
+class ASTNode {
+    void accept(Visitor);
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295astcodegen.d b/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295astcodegen.d
new file mode 100644 (file)
index 0000000..5eccf6a
--- /dev/null
@@ -0,0 +1,4 @@
+module imports.issue21295astcodegen;
+struct ASTCodegen {
+    import imports.issue21295dtemplate;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295dtemplate.d b/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295dtemplate.d
new file mode 100644 (file)
index 0000000..8864f9e
--- /dev/null
@@ -0,0 +1,3 @@
+module imports.issue21295dtemplate;
+import imports.issue21295ast_node;
+class TemplateParameter : ASTNode { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295visitor.d b/gcc/testsuite/gdc.test/fail_compilation/imports/issue21295visitor.d
new file mode 100644 (file)
index 0000000..3665a7f
--- /dev/null
@@ -0,0 +1,3 @@
+module imports.issue21295visitor;
+import imports.issue21295astcodegen;
+class Visitor { }
diff --git a/gcc/testsuite/gdc.test/fail_compilation/issue21295.d b/gcc/testsuite/gdc.test/fail_compilation/issue21295.d
new file mode 100644 (file)
index 0000000..9916e9b
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+REQUIRED_ARGS: -de
+TEST_OUTPUT:
+---
+fail_compilation/issue21295.d(9): Deprecation: imports.issue21295ast_node.Visitor is not visible from module issue21295
+---
+*/
+import imports.issue21295ast_node;
+Visitor should_fail;