diff options
Diffstat (limited to 'gcc/d/dmd/dsymbol.d')
-rw-r--r-- | gcc/d/dmd/dsymbol.d | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/gcc/d/dmd/dsymbol.d b/gcc/d/dmd/dsymbol.d index cb6c278fc44..74eaa1d8d7a 100644 --- a/gcc/d/dmd/dsymbol.d +++ b/gcc/d/dmd/dsymbol.d @@ -112,12 +112,12 @@ struct Ungag { uint oldgag; - extern (D) this(uint old) + extern (D) this(uint old) nothrow { this.oldgag = old; } - extern (C++) ~this() + extern (C++) ~this() nothrow { global.gag = oldgag; } @@ -255,27 +255,27 @@ extern (C++) class Dsymbol : ASTNode DeprecatedDeclaration depdecl; // customized deprecation message UserAttributeDeclaration userAttribDecl; // user defined attributes - final extern (D) this() + final extern (D) this() nothrow { //printf("Dsymbol::Dsymbol(%p)\n", this); loc = Loc(null, 0, 0); } - final extern (D) this(Identifier ident) + final extern (D) this(Identifier ident) nothrow { //printf("Dsymbol::Dsymbol(%p, ident)\n", this); this.loc = Loc(null, 0, 0); this.ident = ident; } - final extern (D) this(const ref Loc loc, Identifier ident) + final extern (D) this(const ref Loc loc, Identifier ident) nothrow { //printf("Dsymbol::Dsymbol(%p, ident)\n", this); this.loc = loc; this.ident = ident; } - static Dsymbol create(Identifier ident) + static Dsymbol create(Identifier ident) nothrow { return new Dsymbol(ident); } @@ -800,6 +800,22 @@ extern (C++) class Dsymbol : ASTNode if (isAliasDeclaration() && !_scope) setScope(sc); Dsymbol s2 = sds.symtabLookup(this,ident); + /* https://issues.dlang.org/show_bug.cgi?id=17434 + * + * If we are trying to add an import to the symbol table + * that has already been introduced, then keep the one with + * larger visibility. This is fine for imports because if + * we have multiple imports of the same file, if a single one + * is public then the symbol is reachable. + */ + if (auto i1 = isImport()) + { + if (auto i2 = s2.isImport()) + { + if (sc.explicitVisibility && sc.visibility > i2.visibility) + sds.symtab.update(this); + } + } // If using C tag/prototype/forward declaration rules if (sc.flags & SCOPE.Cfile && !this.isImport()) @@ -822,7 +838,8 @@ extern (C++) class Dsymbol : ASTNode } if (sds.isAggregateDeclaration() || sds.isEnumDeclaration()) { - if (ident == Id.__sizeof || ident == Id.__xalignof || ident == Id._mangleof) + if (ident == Id.__sizeof || + !(sc && sc.flags & SCOPE.Cfile) && (ident == Id.__xalignof || ident == Id._mangleof)) { error("`.%s` property cannot be redefined", ident.toChars()); errors = true; @@ -933,14 +950,7 @@ extern (C++) class Dsymbol : ASTNode TemplateInstance ti = st.isTemplateInstance(); sm = s.search(loc, ti.name); if (!sm) - { - sm = s.search_correct(ti.name); - if (sm) - .error(loc, "template identifier `%s` is not a member of %s `%s`, did you mean %s `%s`?", ti.name.toChars(), s.kind(), s.toPrettyChars(), sm.kind(), sm.toChars()); - else - .error(loc, "template identifier `%s` is not a member of %s `%s`", ti.name.toChars(), s.kind(), s.toPrettyChars()); return null; - } sm = sm.toAlias(); TemplateDeclaration td = sm.isTemplateDeclaration(); if (!td) @@ -1381,16 +1391,16 @@ private: BitArray accessiblePackages, privateAccessiblePackages;// whitelists of accessible (imported) packages public: - final extern (D) this() + final extern (D) this() nothrow { } - final extern (D) this(Identifier ident) + final extern (D) this(Identifier ident) nothrow { super(ident); } - final extern (D) this(const ref Loc loc, Identifier ident) + final extern (D) this(const ref Loc loc, Identifier ident) nothrow { super(loc, ident); } @@ -1604,7 +1614,7 @@ public: return os; } - void importScope(Dsymbol s, Visibility visibility) + void importScope(Dsymbol s, Visibility visibility) nothrow { //printf("%s.ScopeDsymbol::importScope(%s, %d)\n", toChars(), s.toChars(), visibility); // No circular or redundant import's @@ -1631,7 +1641,7 @@ public: } } - extern (D) final void addAccessiblePackage(Package p, Visibility visibility) + extern (D) final void addAccessiblePackage(Package p, Visibility visibility) nothrow { auto pary = visibility.kind == Visibility.Kind.private_ ? &privateAccessiblePackages : &accessiblePackages; if (pary.length <= p.tag) @@ -1639,7 +1649,7 @@ public: (*pary)[p.tag] = true; } - bool isPackageAccessible(Package p, Visibility visibility, int flags = 0) + bool isPackageAccessible(Package p, Visibility visibility, int flags = 0) nothrow { if (p.tag < accessiblePackages.length && accessiblePackages[p.tag] || visibility.kind == Visibility.Kind.private_ && p.tag < privateAccessiblePackages.length && privateAccessiblePackages[p.tag]) @@ -1654,7 +1664,7 @@ public: return false; } - override final bool isforwardRef() + override final bool isforwardRef() nothrow { return (members is null); } @@ -1742,7 +1752,7 @@ public: * Returns: * null if already in table, `s` if inserted */ - Dsymbol symtabInsert(Dsymbol s) + Dsymbol symtabInsert(Dsymbol s) nothrow { return symtab.insert(s); } @@ -1755,7 +1765,7 @@ public: * Returns: * Dsymbol if found, null if not */ - Dsymbol symtabLookup(Dsymbol s, Identifier id) + Dsymbol symtabLookup(Dsymbol s, Identifier id) nothrow { return symtab.lookup(id); } @@ -1838,7 +1848,7 @@ extern (C++) final class WithScopeSymbol : ScopeDsymbol { WithStatement withstate; - extern (D) this(WithStatement withstate) + extern (D) this(WithStatement withstate) nothrow { this.withstate = withstate; } @@ -1898,7 +1908,7 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol private RootObject arrayContent; Scope* sc; - extern (D) this(Scope* sc, Expression exp) + extern (D) this(Scope* sc, Expression exp) nothrow { super(exp.loc, null); assert(exp.op == EXP.index || exp.op == EXP.slice || exp.op == EXP.array); @@ -1906,13 +1916,13 @@ extern (C++) final class ArrayScopeSymbol : ScopeDsymbol this.arrayContent = exp; } - extern (D) this(Scope* sc, TypeTuple type) + extern (D) this(Scope* sc, TypeTuple type) nothrow { this.sc = sc; this.arrayContent = type; } - extern (D) this(Scope* sc, TupleDeclaration td) + extern (D) this(Scope* sc, TupleDeclaration td) nothrow { this.sc = sc; this.arrayContent = td; @@ -2109,7 +2119,7 @@ extern (C++) final class OverloadSet : Dsymbol { Dsymbols a; // array of Dsymbols - extern (D) this(Identifier ident, OverloadSet os = null) + extern (D) this(Identifier ident, OverloadSet os = null) nothrow { super(ident); if (os) @@ -2118,7 +2128,7 @@ extern (C++) final class OverloadSet : Dsymbol } } - void push(Dsymbol s) + void push(Dsymbol s) nothrow { a.push(s); } @@ -2152,12 +2162,13 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol * Can be `null` before being lazily initialized. */ ScopeDsymbol forward; - extern (D) this(ScopeDsymbol forward) + extern (D) this(ScopeDsymbol forward) nothrow { super(null); this.forward = forward; } - override Dsymbol symtabInsert(Dsymbol s) + + override Dsymbol symtabInsert(Dsymbol s) nothrow { assert(forward); if (auto d = s.isDeclaration()) @@ -2188,7 +2199,7 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol * and * static foreach (i; [0]) { enum i = 2; } */ - override Dsymbol symtabLookup(Dsymbol s, Identifier id) + override Dsymbol symtabLookup(Dsymbol s, Identifier id) nothrow { assert(forward); // correctly diagnose clashing foreach loop variables. @@ -2219,7 +2230,7 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol override const(char)* kind()const{ return "local scope"; } - override inout(ForwardingScopeDsymbol) isForwardingScopeDsymbol() inout + override inout(ForwardingScopeDsymbol) isForwardingScopeDsymbol() inout nothrow { return this; } @@ -2234,13 +2245,13 @@ extern (C++) final class ForwardingScopeDsymbol : ScopeDsymbol extern (C++) final class ExpressionDsymbol : Dsymbol { Expression exp; - this(Expression exp) + this(Expression exp) nothrow { super(); this.exp = exp; } - override inout(ExpressionDsymbol) isExpressionDsymbol() inout + override inout(ExpressionDsymbol) isExpressionDsymbol() inout nothrow { return this; } @@ -2259,7 +2270,7 @@ extern (C++) final class AliasAssign : Dsymbol Dsymbol aliassym; /// replace previous RHS of AliasDeclaration with `aliassym` /// only one of type and aliassym can be != null - extern (D) this(const ref Loc loc, Identifier ident, Type type, Dsymbol aliassym) + extern (D) this(const ref Loc loc, Identifier ident, Type type, Dsymbol aliassym) nothrow { super(loc, null); this.ident = ident; @@ -2299,6 +2310,8 @@ extern (C++) final class DsymbolTable : RootObject { AssocArray!(Identifier, Dsymbol) tab; + nothrow: + /*************************** * Look up Identifier in symbol table * Params: @@ -2511,6 +2524,7 @@ Dsymbol handleSymbolRedeclarations(ref Scope sc, Dsymbol s, Dsymbol s2, ScopeDsy if (i1) // vd is the definition { + vd2.storage_class |= STC.extern_; // so toObjFile() won't emit it sds.symtab.update(vd); // replace vd2 with the definition return vd; } |