[pkg-d-commits] [ldc] 03/211: Merge DDMD commit '8679fd9b9b5f401f834047cd0c14ebd338566cfd' (== current dlang/stable == tag v2.071.2-b4 + fix for Issue 16460)
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:36:04 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.1.0
in repository ldc.
commit 9d99f59acd5e4c0bbc64a8f156e7d44e2f4bbe45
Author: Johan Engelen <jbc.engelen at gmail.com>
Date: Tue Sep 13 16:10:31 2016 +0200
Merge DDMD commit '8679fd9b9b5f401f834047cd0c14ebd338566cfd' (== current dlang/stable == tag v2.071.2-b4 + fix for Issue 16460)
(no runtime lib updates)
---
ddmd/dscope.d | 11 ++++++++---
ddmd/expression.d | 15 +++++++++++----
ddmd/func.d | 10 +++++++++-
ddmd/mtype.d | 12 ++++++------
ddmd/scope.h | 3 ++-
ddmd/traits.d | 16 ++++++++++------
tests/d2/dmd-testsuite | 2 +-
7 files changed, 47 insertions(+), 22 deletions(-)
diff --git a/ddmd/dscope.d b/ddmd/dscope.d
index c7d6626..fdb06c2 100644
--- a/ddmd/dscope.d
+++ b/ddmd/dscope.d
@@ -91,11 +91,11 @@ enum CSXhalt = 0x80; // assert(0)
// Flags that would not be inherited beyond scope nesting
enum SCOPEctor = 0x0001; // constructor type
-enum SCOPEnoaccesscheck = 0x0002; // don't do access checks
enum SCOPEcondition = 0x0004; // inside static if/assert condition
enum SCOPEdebug = 0x0008; // inside debug conditional
// Flags that would be inherited beyond scope nesting
+enum SCOPEnoaccesscheck = 0x0002; // don't do access checks
enum SCOPEconstraint = 0x0010; // inside template constraint
enum SCOPEinvariant = 0x0020; // inside invariant code
enum SCOPErequire = 0x0040; // inside in contract code
@@ -103,6 +103,7 @@ enum SCOPEensure = 0x0060; // inside out contract code
enum SCOPEcontract = 0x0060; // [mask] we're inside contract code
enum SCOPEctfe = 0x0080; // inside a ctfe-only expression
enum SCOPEcompile = 0x0100; // inside __traits(compile)
+enum SCOPEignoresymbolvisibility = 0x0200; // ignore symbol visibility (Bugzilla 15907)
enum SCOPEfree = 0x8000; // is on free list
enum SCOPEfullinst = 0x10000; // fully instantiate templates
@@ -246,7 +247,8 @@ version(IN_LLVM)
s.slabel = null;
s.nofree = 0;
s.fieldinit = saveFieldInit();
- s.flags = (flags & (SCOPEcontract | SCOPEdebug | SCOPEctfe | SCOPEcompile | SCOPEconstraint));
+ s.flags = (flags & (SCOPEcontract | SCOPEdebug | SCOPEctfe | SCOPEcompile | SCOPEconstraint |
+ SCOPEnoaccesscheck | SCOPEignoresymbolvisibility));
s.lastdc = null;
assert(&this != s);
return s;
@@ -527,6 +529,9 @@ else
return null;
}
+ if (this.flags & SCOPEignoresymbolvisibility)
+ flags |= IgnoreSymbolVisibility;
+
Dsymbol sold = void;
if (global.params.bug10378 || global.params.check10378)
{
@@ -553,7 +558,7 @@ else
* checked by the compiler remain usable. Once the deprecation is over,
* this should be moved to search_correct instead.
*/
- if (!s)
+ if (!s && !(flags & IgnoreSymbolVisibility))
{
s = searchScopes(flags | SearchLocalsOnly | IgnoreSymbolVisibility);
if (!s)
diff --git a/ddmd/expression.d b/ddmd/expression.d
index c6628ee..456becc 100644
--- a/ddmd/expression.d
+++ b/ddmd/expression.d
@@ -684,6 +684,9 @@ extern (C++) Expression searchUFCS(Scope* sc, UnaExp ue, Identifier ident)
int flags = 0;
Dsymbol s;
+ if (sc.flags & SCOPEignoresymbolvisibility)
+ flags |= IgnoreSymbolVisibility;
+
Dsymbol sold = void;
if (global.params.bug10378 || global.params.check10378)
{
@@ -706,7 +709,7 @@ extern (C++) Expression searchUFCS(Scope* sc, UnaExp ue, Identifier ident)
* checked by the compiler remain usable. Once the deprecation is over,
* this should be moved to search_correct instead.
*/
- if (!s)
+ if (!s && !(flags & IgnoreSymbolVisibility))
{
s = searchScopes(flags | SearchLocalsOnly | IgnoreSymbolVisibility);
if (!s)
@@ -8365,16 +8368,20 @@ public:
if (eright.op == TOKscope) // also used for template alias's
{
ScopeExp ie = cast(ScopeExp)eright;
+ int flags = SearchLocalsOnly;
/* Disable access to another module's private imports.
* The check for 'is sds our current module' is because
* the current module should have access to its own imports.
*/
- Dsymbol s = ie.sds.search(loc, ident,
- (ie.sds.isModule() && ie.sds != sc._module) ? IgnorePrivateImports | SearchLocalsOnly : SearchLocalsOnly);
+ if (ie.sds.isModule() && ie.sds != sc._module)
+ flags |= IgnorePrivateImports;
+ if (sc.flags & SCOPEignoresymbolvisibility)
+ flags |= IgnoreSymbolVisibility;
+ Dsymbol s = ie.sds.search(loc, ident, flags);
/* Check for visibility before resolving aliases because public
* aliases to private symbols are public.
*/
- if (s && !symbolIsVisible(sc._module, s))
+ if (s && !(sc.flags & SCOPEignoresymbolvisibility) && !symbolIsVisible(sc._module, s))
{
if (s.isDeclaration())
.error(loc, "%s is not visible from module %s", s.toPrettyChars(), sc._module.toChars());
diff --git a/ddmd/func.d b/ddmd/func.d
index b1f7293..518ed63 100644
--- a/ddmd/func.d
+++ b/ddmd/func.d
@@ -1518,7 +1518,15 @@ public:
localsymtab = new DsymbolTable();
// Establish function scope
auto ss = new ScopeDsymbol();
- ss.parent = sc.scopesym;
+ // find enclosing scope symbol, might skip symbol-less CTFE and/or FuncExp scopes
+ for (auto scx = sc; ; scx = scx.enclosing)
+ {
+ if (scx.scopesym)
+ {
+ ss.parent = scx.scopesym;
+ break;
+ }
+ }
Scope* sc2 = sc.push(ss);
sc2.func = this;
sc2.parent = this;
diff --git a/ddmd/mtype.d b/ddmd/mtype.d
index 13b59cd..2836f03 100644
--- a/ddmd/mtype.d
+++ b/ddmd/mtype.d
@@ -7098,7 +7098,7 @@ public:
Type t = s.getType(); // type symbol, type alias, or type tuple?
uint errorsave = global.errors;
Dsymbol sm = s.searchX(loc, sc, id);
- if (sm && !symbolIsVisible(sc, sm))
+ if (sm && !(sc.flags & SCOPEignoresymbolvisibility) && !symbolIsVisible(sc, sm))
{
.deprecation(loc, "%s is not visible from module %s", sm.toPrettyChars(), sc._module.toChars());
// sm = null;
@@ -7968,7 +7968,7 @@ public:
Dsymbol searchSym()
{
- int flags = 0;
+ int flags = sc.flags & SCOPEignoresymbolvisibility ? IgnoreSymbolVisibility : 0;
Dsymbol sold = void;
if (global.params.bug10378 || global.params.check10378)
{
@@ -8001,7 +8001,7 @@ public:
if (!s)
return noMember(sc, e, ident, flag);
}
- if (!symbolIsVisible(sc, s))
+ if (!(sc.flags & SCOPEignoresymbolvisibility) && !symbolIsVisible(sc, s))
{
.deprecation(e.loc, "%s is not visible from module %s", s.toPrettyChars(), sc._module.toPrettyChars());
// return noMember(sc, e, ident, flag);
@@ -8778,7 +8778,7 @@ public:
Dsymbol searchSym()
{
- int flags = 0;
+ int flags = sc.flags & SCOPEignoresymbolvisibility ? IgnoreSymbolVisibility : 0;
Dsymbol sold = void;
if (global.params.bug10378 || global.params.check10378)
{
@@ -8788,7 +8788,7 @@ public:
}
auto s = sym.search(e.loc, ident, flags | SearchLocalsOnly);
- if (!s)
+ if (!s && !(flags & IgnoreSymbolVisibility))
{
s = sym.search(e.loc, ident, flags | SearchLocalsOnly | IgnoreSymbolVisibility);
if (s && !(flags & IgnoreErrors))
@@ -8941,7 +8941,7 @@ public:
return noMember(sc, e, ident, flag);
}
}
- if (!symbolIsVisible(sc, s))
+ if (!(sc.flags & SCOPEignoresymbolvisibility) && !symbolIsVisible(sc, s))
{
.deprecation(e.loc, "%s is not visible from module %s", s.toPrettyChars(), sc._module.toChars());
// return noMember(sc, e, ident, flag);
diff --git a/ddmd/scope.h b/ddmd/scope.h
index 2a7d6c1..a9ed8e8 100644
--- a/ddmd/scope.h
+++ b/ddmd/scope.h
@@ -54,11 +54,11 @@ enum PINLINE;
// Flags that would not be inherited beyond scope nesting
#define SCOPEctor 0x0001 // constructor type
-#define SCOPEnoaccesscheck 0x0002 // don't do access checks
#define SCOPEcondition 0x0004 // inside static if/assert condition
#define SCOPEdebug 0x0008 // inside debug conditional
// Flags that would be inherited beyond scope nesting
+#define SCOPEnoaccesscheck 0x0002 // don't do access checks
#define SCOPEconstraint 0x0010 // inside template constraint
#define SCOPEinvariant 0x0020 // inside invariant code
#define SCOPErequire 0x0040 // inside in contract code
@@ -66,6 +66,7 @@ enum PINLINE;
#define SCOPEcontract 0x0060 // [mask] we're inside contract code
#define SCOPEctfe 0x0080 // inside a ctfe-only expression
#define SCOPEcompile 0x0100 // inside __traits(compile)
+#define SCOPEignoresymbolvisibility 0x0200 // ignore symbol visibility (Bugzilla 15907)
#define SCOPEfree 0x8000 // is on free list
diff --git a/ddmd/traits.d b/ddmd/traits.d
index 0348326..cf95f45 100644
--- a/ddmd/traits.d
+++ b/ddmd/traits.d
@@ -685,6 +685,12 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
e.error("invalid first argument");
return new ErrorExp();
}
+
+ // ignore symbol visibility for these traits, should disable access checks as well
+ Scope* scx = sc.push();
+ scx.flags |= SCOPEignoresymbolvisibility;
+ scope (exit) scx.pop();
+
if (e.ident == Id.hasMember)
{
if (sym)
@@ -695,9 +701,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
/* Take any errors as meaning it wasn't found
*/
- Scope* sc2 = sc.push();
- ex = ex.trySemantic(sc2);
- sc2.pop();
+ ex = ex.trySemantic(scx);
if (!ex)
goto Lfalse;
else
@@ -705,7 +709,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
}
else if (e.ident == Id.getMember)
{
- ex = ex.semantic(sc);
+ ex = ex.semantic(scx);
return ex;
}
else if (e.ident == Id.getVirtualFunctions ||
@@ -714,7 +718,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
{
uint errors = global.errors;
Expression eorig = ex;
- ex = ex.semantic(sc);
+ ex = ex.semantic(scx);
if (errors < global.errors)
e.error("%s cannot be resolved", eorig.toChars());
//ex->print();
@@ -760,7 +764,7 @@ extern (C++) Expression semanticTraits(TraitsExp e, Scope* sc)
});
auto tup = new TupleExp(e.loc, exps);
- return tup.semantic(sc);
+ return tup.semantic(scx);
}
else
assert(0);
diff --git a/tests/d2/dmd-testsuite b/tests/d2/dmd-testsuite
index 72b879d..b85b868 160000
--- a/tests/d2/dmd-testsuite
+++ b/tests/d2/dmd-testsuite
@@ -1 +1 @@
-Subproject commit 72b879d13ad59513a04aa1512d2635f97bbbb793
+Subproject commit b85b868a0bebfdf8042f93bdba5aec1c366a1655
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list