diff options
Diffstat (limited to 'gcc/d/dmd/traits.d')
-rw-r--r-- | gcc/d/dmd/traits.d | 80 |
1 files changed, 23 insertions, 57 deletions
diff --git a/gcc/d/dmd/traits.d b/gcc/d/dmd/traits.d index 4b15e8c4739..04e1c47d16e 100644 --- a/gcc/d/dmd/traits.d +++ b/gcc/d/dmd/traits.d @@ -1278,7 +1278,7 @@ Expression semanticTraits(TraitsExp e, Scope* sc) { s = s.isImport().mod; } - //printf("getAttributes %s, attrs = %p, scope = %p\n", s.toChars(), s.userAttribDecl, s.scope); + //printf("getAttributes %s, attrs = %p, scope = %p\n", s.toChars(), s.userAttribDecl, s._scope); udad = s.userAttribDecl; } else @@ -1514,7 +1514,9 @@ Expression semanticTraits(TraitsExp e, Scope* sc) TypeFunction tf = toTypeFunction(o, fd); if (tf) - link = tf.linkage; + { + link = fd ? fd.linkage : tf.linkage; + } else { auto s = getDsymbol(o); @@ -1730,69 +1732,33 @@ Expression semanticTraits(TraitsExp e, Scope* sc) bool err = false; auto t = isType(o); - while (t) + auto ex = isExpression(o); + if (t) { - if (auto tm = t.isTypeMixin()) + Dsymbol s; + t.resolve(e.loc, sc2, ex, t, s); + if (t) { - /* The mixin string could be a type or an expression. - * Have to try compiling it to see. - */ - OutBuffer buf; - if (expressionsToString(buf, sc, tm.exps)) - { + t.typeSemantic(e.loc, sc2); + if (t.ty == Terror) err = true; - break; - } - const olderrors = global.errors; - const len = buf.length; - buf.writeByte(0); - const str = buf.extractSlice()[0 .. len]; - scope p = new Parser!ASTCodegen(e.loc, sc._module, str, false); - p.nextToken(); - //printf("p.loc.linnum = %d\n", p.loc.linnum); - - o = p.parseTypeOrAssignExp(TOK.endOfFile); - if (olderrors != global.errors || p.token.value != TOK.endOfFile) - { - err = true; - break; - } - t = o.isType(); } - else - break; + else if (s && s.errors) + err = true; } - - if (!err) + if (ex) { - auto ex = t ? t.typeToExpression() : isExpression(o); - if (!ex && t) - { - Dsymbol s; - t.resolve(e.loc, sc2, ex, t, s); - if (t) - { - t.typeSemantic(e.loc, sc2); - if (t.ty == Terror) - err = true; - } - else if (s && s.errors) - err = true; - } - if (ex) + ex = ex.expressionSemantic(sc2); + ex = resolvePropertiesOnly(sc2, ex); + ex = ex.optimize(WANTvalue); + if (sc2.func && sc2.func.type.ty == Tfunction) { - ex = ex.expressionSemantic(sc2); - ex = resolvePropertiesOnly(sc2, ex); - ex = ex.optimize(WANTvalue); - if (sc2.func && sc2.func.type.ty == Tfunction) - { - const tf = cast(TypeFunction)sc2.func.type; - err |= tf.isnothrow && canThrow(ex, sc2.func, false); - } - ex = checkGC(sc2, ex); - if (ex.op == EXP.error) - err = true; + const tf = cast(TypeFunction)sc2.func.type; + err |= tf.isnothrow && canThrow(ex, sc2.func, false); } + ex = checkGC(sc2, ex); + if (ex.op == EXP.error) + err = true; } // Carefully detach the scope from the parent and throw it away as |