diff options
Diffstat (limited to 'gcc/d/dmd/attrib.d')
-rw-r--r-- | gcc/d/dmd/attrib.d | 58 |
1 files changed, 41 insertions, 17 deletions
diff --git a/gcc/d/dmd/attrib.d b/gcc/d/dmd/attrib.d index 9c2bbd672a7..1e84b55d181 100644 --- a/gcc/d/dmd/attrib.d +++ b/gcc/d/dmd/attrib.d @@ -44,7 +44,6 @@ import dmd.mtype; import dmd.objc; // for objc.addSymbols import dmd.common.outbuffer; import dmd.root.array; // for each -import dmd.target; // for target.systemLinkage import dmd.tokens; import dmd.visitor; @@ -399,7 +398,7 @@ extern (C++) final class LinkDeclaration : AttribDeclaration { super(loc, null, decl); //printf("LinkDeclaration(linkage = %d, decl = %p)\n", linkage, decl); - this.linkage = (linkage == LINK.system) ? target.systemLinkage() : linkage; + this.linkage = linkage; } static LinkDeclaration create(const ref Loc loc, LINK p, Dsymbols* decl) @@ -994,7 +993,7 @@ extern (C++) class ConditionalDeclaration : AttribDeclaration // Decide if 'then' or 'else' code should be included override Dsymbols* include(Scope* sc) { - //printf("ConditionalDeclaration::include(sc = %p) scope = %p\n", sc, scope); + //printf("ConditionalDeclaration::include(sc = %p) scope = %p\n", sc, _scope); if (errors) return null; @@ -1057,7 +1056,7 @@ extern (C++) final class StaticIfDeclaration : ConditionalDeclaration */ override Dsymbols* include(Scope* sc) { - //printf("StaticIfDeclaration::include(sc = %p) scope = %p\n", sc, scope); + //printf("StaticIfDeclaration::include(sc = %p) scope = %p\n", sc, _scope); if (errors || onStack) return null; @@ -1496,12 +1495,7 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration if (global.params.cplusplus < CppStdRevision.cpp11) return; - // Avoid `if` at the call site - if (sym.userAttribDecl is null || sym.userAttribDecl.atts is null) - return; - - foreach (exp; *sym.userAttribDecl.atts) - { + foreachUdaNoSemantic(sym, (exp) { if (isGNUABITag(exp)) { if (sym.isCPPNamespaceDeclaration() || sym.isNspace()) @@ -1515,9 +1509,10 @@ extern (C++) final class UserAttributeDeclaration : AttribDeclaration sym.errors = true; } // Only one `@gnuAbiTag` is allowed by semantic2 - return; + return 1; // break } - } + return 0; // continue + }); } } @@ -1544,14 +1539,14 @@ bool isCoreUda(Dsymbol sym, Identifier ident) /** * Iterates the UDAs attached to the given symbol. * - * If `dg` returns `!= 0`, it will stop the iteration and return that - * value, otherwise it will return 0. - * * Params: * sym = the symbol to get the UDAs from * sc = scope to use for semantic analysis of UDAs - * dg = called once for each UDA. If `dg` returns `!= 0`, it will stop the - * iteration and return that value, otherwise it will return `0`. + * dg = called once for each UDA + * + * Returns: + * If `dg` returns `!= 0`, stops the iteration and returns that value. + * Otherwise, returns 0. */ int foreachUda(Dsymbol sym, Scope* sc, int delegate(Expression) dg) { @@ -1577,3 +1572,32 @@ int foreachUda(Dsymbol sym, Scope* sc, int delegate(Expression) dg) }); }); } + +/** + * Iterates the UDAs attached to the given symbol, without performing semantic + * analysis. + * + * Use this function instead of `foreachUda` if semantic analysis of `sym` is + * still in progress. + * + * Params: + * sym = the symbol to get the UDAs from + * dg = called once for each UDA + * + * Returns: + * If `dg` returns `!= 0`, stops the iteration and returns that value. + * Otherwise, returns 0. + */ +int foreachUdaNoSemantic(Dsymbol sym, int delegate(Expression) dg) +{ + if (sym.userAttribDecl is null || sym.userAttribDecl.atts is null) + return 0; + + foreach (exp; *sym.userAttribDecl.atts) + { + if (auto result = dg(exp)) + return result; + } + + return 0; +} |