diff --git a/compiler/src/dmd/astbase.d b/compiler/src/dmd/astbase.d index 23a75f8127bb..a840f4d185ee 100644 --- a/compiler/src/dmd/astbase.d +++ b/compiler/src/dmd/astbase.d @@ -4605,11 +4605,7 @@ struct ASTBase inout(IdentityExp) isIdentityExp() { return (op == EXP.identity || op == EXP.notIdentity) ? cast(typeof(return))this : null; } inout(CondExp) isCondExp() { return op == EXP.question ? cast(typeof(return))this : null; } inout(GenericExp) isGenericExp() { return op == EXP._Generic ? cast(typeof(return))this : null; } - inout(FileInitExp) isFileInitExp() { return (op == EXP.file || op == EXP.fileFullPath) ? cast(typeof(return))this : null; } - inout(LineInitExp) isLineInitExp() { return op == EXP.line ? cast(typeof(return))this : null; } - inout(ModuleInitExp) isModuleInitExp() { return op == EXP.moduleString ? cast(typeof(return))this : null; } - inout(FuncInitExp) isFuncInitExp() { return op == EXP.functionString ? cast(typeof(return))this : null; } - inout(PrettyFuncInitExp) isPrettyFuncInitExp() { return op == EXP.prettyFunction ? cast(typeof(return))this : null; } + inout(DefaultInitExp) isDefaultInitExp() { return op == EXP.defaultInit ? cast(typeof(return))this : null; } inout(AssignExp) isConstructExp() { return op == EXP.construct ? cast(typeof(return))this : null; } inout(AssignExp) isBlitExp() { return op == EXP.blit ? cast(typeof(return))this : null; } @@ -5139,9 +5135,12 @@ struct ASTBase extern (C++) class DefaultInitExp : Expression { - final extern (D) this(Loc loc, EXP op, int size) + TOK tok; /// which special token this is + + final extern (D) this(Loc loc, TOK tok) { - super(loc, op, size); + super(loc, EXP.defaultInit, __traits(classInstanceSize, DefaultInitExp)); + this.tok = tok; } override void accept(Visitor v) @@ -5681,70 +5680,6 @@ struct ASTBase } } - extern (C++) final class FuncInitExp : DefaultInitExp - { - extern (D) this(Loc loc) - { - super(loc, EXP.functionString, __traits(classInstanceSize, FuncInitExp)); - } - - override void accept(Visitor v) - { - v.visit(this); - } - } - - extern (C++) final class PrettyFuncInitExp : DefaultInitExp - { - extern (D) this(Loc loc) - { - super(loc, EXP.prettyFunction, __traits(classInstanceSize, PrettyFuncInitExp)); - } - - override void accept(Visitor v) - { - v.visit(this); - } - } - - extern (C++) final class FileInitExp : DefaultInitExp - { - extern (D) this(Loc loc, EXP tok) - { - super(loc, tok, __traits(classInstanceSize, FileInitExp)); - } - - override void accept(Visitor v) - { - v.visit(this); - } - } - - extern (C++) final class LineInitExp : DefaultInitExp - { - extern (D) this(Loc loc) - { - super(loc, EXP.line, __traits(classInstanceSize, LineInitExp)); - } - - override void accept(Visitor v) - { - v.visit(this); - } - } - - extern (C++) final class ModuleInitExp : DefaultInitExp - { - extern (D) this(Loc loc) - { - super(loc, EXP.moduleString, __traits(classInstanceSize, ModuleInitExp)); - } - - override void accept(Visitor v) - { - v.visit(this); - } - } extern (C++) final class CommaExp : BinExp { diff --git a/compiler/src/dmd/dfa/fast/expression.d b/compiler/src/dmd/dfa/fast/expression.d index 9ebf88c6e134..25b3d15453ad 100644 --- a/compiler/src/dmd/dfa/fast/expression.d +++ b/compiler/src/dmd/dfa/fast/expression.d @@ -1549,12 +1549,7 @@ struct ExpressionWalker case EXP.traits: case EXP.overloadSet: - case EXP.line: - case EXP.file: - case EXP.fileFullPath: - case EXP.moduleString: // __MODULE__ - case EXP.functionString: // __FUNCTION__ - case EXP.prettyFunction: // __PRETTY_FUNCTION__ + case EXP.defaultInit: case EXP.voidExpression: case EXP.cantExpression: diff --git a/compiler/src/dmd/dscope.d b/compiler/src/dmd/dscope.d index f65e02970419..6e20a1893dc6 100644 --- a/compiler/src/dmd/dscope.d +++ b/compiler/src/dmd/dscope.d @@ -29,6 +29,7 @@ import dmd.errorsink; import dmd.func; import dmd.globals; import dmd.identifier; +import dmd.location : Loc; import dmd.root.rmem; import dmd.statement; @@ -145,6 +146,7 @@ extern (C++) struct Scope Statement scontinue; /// enclosing statement that supports "continue" ForeachStatement fes; /// if nested function for ForeachStatement, this is it Scope* callsc; /// used for __FUNCTION__, __PRETTY_FUNCTION__ and __MODULE__ + Loc callLoc; /// call-site location for __FILE__, __LINE__, and __FILE_FULL_PATH__ Dsymbol inunion; /// != null if processing members of a union VarDeclaration lastVar; /// Previous symbol used to prevent goto-skips-init ErrorSink eSink; /// sink for error messages diff --git a/compiler/src/dmd/expression.d b/compiler/src/dmd/expression.d index f5fbf805de17..d51048346769 100644 --- a/compiler/src/dmd/expression.d +++ b/compiler/src/dmd/expression.d @@ -451,15 +451,7 @@ extern (C++) abstract class Expression : ASTNode inout(IdentityExp) isIdentityExp() { return (op == EXP.identity || op == EXP.notIdentity) ? cast(typeof(return))this : null; } inout(CondExp) isCondExp() { return op == EXP.question ? cast(typeof(return))this : null; } inout(GenericExp) isGenericExp() { return op == EXP._Generic ? cast(typeof(return))this : null; } - inout(DefaultInitExp) isDefaultInitExp() { return - (op == EXP.prettyFunction || op == EXP.functionString || - op == EXP.line || op == EXP.moduleString || - op == EXP.file || op == EXP.fileFullPath ) ? cast(typeof(return))this : null; } - inout(FileInitExp) isFileInitExp() { return (op == EXP.file || op == EXP.fileFullPath) ? cast(typeof(return))this : null; } - inout(LineInitExp) isLineInitExp() { return op == EXP.line ? cast(typeof(return))this : null; } - inout(ModuleInitExp) isModuleInitExp() { return op == EXP.moduleString ? cast(typeof(return))this : null; } - inout(FuncInitExp) isFuncInitExp() { return op == EXP.functionString ? cast(typeof(return))this : null; } - inout(PrettyFuncInitExp) isPrettyFuncInitExp() { return op == EXP.prettyFunction ? cast(typeof(return))this : null; } + inout(DefaultInitExp) isDefaultInitExp() { return op == EXP.defaultInit ? cast(typeof(return))this : null; } inout(ObjcClassReferenceExp) isObjcClassReferenceExp() { return op == EXP.objcClassReference ? cast(typeof(return))this : null; } inout(ClassReferenceExp) isClassReferenceExp() { return op == EXP.classReference ? cast(typeof(return))this : null; } inout(ThrownExceptionExp) isThrownExceptionExp() { return op == EXP.thrownException ? cast(typeof(return))this : null; } @@ -3791,100 +3783,22 @@ extern (C++) final class CondExp : BinExp */ extern (C++) class DefaultInitExp : Expression { - /************************* - * Params: - * loc = location - * op = EXP.prettyFunction, EXP.functionString, EXP.moduleString, - * EXP.line, EXP.file, EXP.fileFullPath - */ - extern (D) this(Loc loc, EXP op) @safe - { - super(loc, op); - } - - override void accept(Visitor v) - { - v.visit(this); - } -} - -/*********************************************************** - * The `__FILE__` token as a default argument - */ -extern (C++) final class FileInitExp : DefaultInitExp -{ - extern (D) this(Loc loc, EXP tok) @safe - { - super(loc, tok); - } - - override void accept(Visitor v) - { - v.visit(this); - } -} - -/*********************************************************** - * The `__LINE__` token as a default argument - */ -extern (C++) final class LineInitExp : DefaultInitExp -{ - extern (D) this(Loc loc) @safe - { - super(loc, EXP.line); - } - - override void accept(Visitor v) - { - v.visit(this); - } -} + TOK tok; /// which special token this is -/*********************************************************** - * The `__MODULE__` token as a default argument - */ -extern (C++) final class ModuleInitExp : DefaultInitExp -{ - extern (D) this(Loc loc) @safe + extern (D) this(Loc loc, TOK tok) @safe { - super(loc, EXP.moduleString); - } - - override void accept(Visitor v) - { - v.visit(this); - } -} - -/*********************************************************** - * The `__FUNCTION__` token as a default argument - */ -extern (C++) final class FuncInitExp : DefaultInitExp -{ - extern (D) this(Loc loc) @safe - { - super(loc, EXP.functionString); + super(loc, EXP.defaultInit); + this.tok = tok; } override void accept(Visitor v) { v.visit(this); } -} - -/*********************************************************** - * The `__PRETTY_FUNCTION__` token as a default argument - */ -extern (C++) final class PrettyFuncInitExp : DefaultInitExp -{ - extern (D) this(Loc loc) @safe - { - super(loc, EXP.prettyFunction); - } - override void accept(Visitor v) + override Expression syntaxCopy() { - v.visit(this); + return new DefaultInitExp(loc, tok); } } @@ -4221,12 +4135,7 @@ private immutable ubyte[EXP.max+1] expSize = [ EXP.scope_: __traits(classInstanceSize, ScopeExp), EXP.traits: __traits(classInstanceSize, TraitsExp), EXP.overloadSet: __traits(classInstanceSize, OverExp), - EXP.line: __traits(classInstanceSize, LineInitExp), - EXP.file: __traits(classInstanceSize, FileInitExp), - EXP.fileFullPath: __traits(classInstanceSize, FileInitExp), - EXP.moduleString: __traits(classInstanceSize, ModuleInitExp), - EXP.functionString: __traits(classInstanceSize, FuncInitExp), - EXP.prettyFunction: __traits(classInstanceSize, PrettyFuncInitExp), + EXP.defaultInit: __traits(classInstanceSize, DefaultInitExp), EXP.pow: __traits(classInstanceSize, PowExp), EXP.powAssign: __traits(classInstanceSize, PowAssignExp), EXP.vector: __traits(classInstanceSize, VectorExp), diff --git a/compiler/src/dmd/expression.h b/compiler/src/dmd/expression.h index d3896125bd83..acf9285161e7 100644 --- a/compiler/src/dmd/expression.h +++ b/compiler/src/dmd/expression.h @@ -217,11 +217,6 @@ class Expression : public ASTNode CondExp* isCondExp(); GenericExp* isGenericExp(); DefaultInitExp* isDefaultInitExp(); - FileInitExp* isFileInitExp(); - LineInitExp* isLineInitExp(); - ModuleInitExp* isModuleInitExp(); - FuncInitExp* isFuncInitExp(); - PrettyFuncInitExp* isPrettyFuncInitExp(); ClassReferenceExp* isClassReferenceExp(); ThrownExceptionExp* isThrownExceptionExp(); UnaExp* isUnaExp(); @@ -1263,37 +1258,9 @@ class GenericExp final : Expression class DefaultInitExp : public Expression { public: + TOK tok; void accept(Visitor *v) override { v->visit(this); } -}; - -class FileInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor *v) override { v->visit(this); } -}; - -class LineInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor *v) override { v->visit(this); } -}; - -class ModuleInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor *v) override { v->visit(this); } -}; - -class FuncInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor *v) override { v->visit(this); } -}; - -class PrettyFuncInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor *v) override { v->visit(this); } + Expression* syntaxCopy() override; }; /****************************************************************/ diff --git a/compiler/src/dmd/expressionsem.d b/compiler/src/dmd/expressionsem.d index 7c5bfc3b5052..da1d253d3fbd 100644 --- a/compiler/src/dmd/expressionsem.d +++ b/compiler/src/dmd/expressionsem.d @@ -3086,6 +3086,8 @@ private bool checkPurity(FuncDeclaration f, Loc loc, Scope* sc) return false; if (sc.ctfe || sc.debug_) return false; + if (sc.inDefaultArg || sc.callLoc.isValid) + return false; // If the call has a pure parent, then the called func must be pure. if (!f.isPure() && checkImpure(sc, loc, null, f)) @@ -3391,6 +3393,8 @@ private bool checkSafety(FuncDeclaration f, ref Loc loc, Scope* sc, Expressions* return false; if (sc.ctfe && sc.func) return false; + if (sc.inDefaultArg || sc.callLoc.isValid) + return false; if (!sc.func) { @@ -3492,6 +3496,9 @@ private bool checkNogc(FuncDeclaration f, ref Loc loc, Scope* sc) return false; if (sc.ctfe || sc.debug_) return false; + if (sc.inDefaultArg || sc.callLoc.isValid) + return false; + /* The original expressions (`new S(...)` or `new S[...]``) will be * verified instead. This is to keep errors related to the original code * and not the lowering. @@ -4245,12 +4252,14 @@ private bool functionParameters(Loc loc, Scope* sc, goto L2; return errorArgs(); } - arg = p.defaultArg; - if (!arg.type) - arg = arg.expressionSemantic(sc); - arg = inlineCopy(arg, sc); - // __FILE__, __LINE__, __MODULE__, __FUNCTION__, and __PRETTY_FUNCTION__ - arg = arg.resolveLoc(loc, sc); + arg = p.defaultArg.syntaxCopy(); + { + Scope* sc2 = sc.push(); + sc2.callLoc = loc; + arg = arg.expressionSemantic(sc2); + sc2.pop(); + } + arg.loc = loc; // update loc for debug info if (i >= nargs) { arguments.push(arg); @@ -4261,7 +4270,11 @@ private bool functionParameters(Loc loc, Scope* sc, } else if (arg.isDefaultInitExp()) { - arg = arg.resolveLoc(loc, sc); + Scope* sc2 = sc.push(); + sc2.callLoc = loc; + arg = arg.expressionSemantic(sc2); + sc2.pop(); + arg.loc = loc; // update loc for debug info (*arguments)[i] = arg; } else if (!(p.storageClass & (STC.ref_ | STC.out_))) @@ -15501,38 +15514,77 @@ private extern (C++) final class ExpressionSemanticVisitor : Visitor result = exps[imatch]; } - override void visit(FileInitExp e) + override void visit(DefaultInitExp e) { - //printf("FileInitExp::semantic()\n"); - e.type = Type.tstring; - result = e.resolveLoc(e.loc, sc); - } + e.type = e.tok == TOK.line ? Type.tint32 : Type.tstring; - override void visit(LineInitExp e) - { - e.type = Type.tint32; - result = e.resolveLoc(e.loc, sc); - } - - override void visit(ModuleInitExp e) - { - //printf("ModuleInitExp::semantic()\n"); - e.type = Type.tstring; - result = e.resolveLoc(e.loc, sc); - } + // Don't replace the special keywords while inside a default argument. + // They are replaced later when copied to the call site. + if (sc.inDefaultArg) + { + result = e; + return; + } - override void visit(FuncInitExp e) - { - //printf("FuncInitExp::semantic()\n"); - e.type = Type.tstring; - result = e.resolveLoc(e.loc, sc); - } + const loc = sc.callLoc.isValid() ? sc.callLoc : e.loc; + e.loc = loc; - override void visit(PrettyFuncInitExp e) - { - //printf("PrettyFuncInitExp::semantic()\n"); - e.type = Type.tstring; - result = e.resolveLoc(e.loc, sc); + switch (e.tok) + { + case TOK.file: + case TOK.fileFullPath: + { + const(char)* s; + if (e.tok == TOK.fileFullPath) + s = FileName.toAbsolute(loc.isValid() ? loc.filename : sc._module.srcfile.toChars()); + else + s = loc.isValid() ? loc.filename : sc._module.ident.toErrMsg(); + result = new StringExp(loc, s.toDString()).expressionSemantic(sc); + break; + } + case TOK.line: + result = new IntegerExp(loc, loc.linnum, Type.tint32).expressionSemantic(sc); + break; + case TOK.moduleString: + { + const auto s = (sc.callsc ? sc.callsc : sc)._module.toPrettyChars().toDString(); + result = new StringExp(loc, s).expressionSemantic(sc); + break; + } + case TOK.functionString: + { + const(char)* s; + if (sc.callsc && sc.callsc.func) + s = sc.callsc.func.Dsymbol.toPrettyChars(); + else if (sc.func) + s = sc.func.Dsymbol.toPrettyChars(); + else + s = ""; + result = new StringExp(loc, s.toDString()).expressionSemantic(sc); + break; + } + case TOK.prettyFunction: + { + FuncDeclaration fd = (sc.callsc && sc.callsc.func) + ? sc.callsc.func + : sc.func; + const(char)* s; + if (fd) + { + const funcStr = fd.Dsymbol.toPrettyChars(); + OutBuffer buf; + functionToBufferWithIdent(fd.type.isTypeFunction(), buf, funcStr, fd.isStatic); + s = buf.extractChars(); + } + else + s = ""; + Expression e2 = new StringExp(loc, s.toDString()).expressionSemantic(sc); + e2.type = Type.tstring; + result = e2; + break; + } + default: assert(0); + } } } @@ -16921,260 +16973,6 @@ bool checkSharedAccess(Expression e, Scope* sc, bool returnRef = false) return check(e, returnRef); } -/**************************************** - * Resolve __FILE__, __LINE__, __MODULE__, __FUNCTION__, __PRETTY_FUNCTION__, __FILE_FULL_PATH__ to loc. - */ -Expression resolveLoc(Expression exp, Loc loc, Scope* sc) -{ - // Don't replace the special keywords, while we are inside a default - // argument. They are replaced later when copied to the call site. - if (sc.inDefaultArg) - return exp; - - exp.loc = loc; - - Expression visit(Expression exp) - { - if (auto binExp = exp.isBinExp()) - { - binExp.e1 = binExp.e1.resolveLoc(loc, sc); - binExp.e2 = binExp.e2.resolveLoc(loc, sc); - return binExp; - } - if (auto unaExp = exp.isUnaExp()) - { - unaExp.e1 = unaExp.e1.resolveLoc(loc, sc); - return unaExp; - } - return exp; - } - - Expression visitCond(CondExp exp) - { - exp.e1 = exp.e1.resolveLoc(loc, sc); - exp.e2 = exp.e2.resolveLoc(loc, sc); - exp.econd = exp.econd.resolveLoc(loc, sc); - return exp; - } - - Expression visitCat(CatExp exp) - { - exp.e1 = exp.e1.resolveLoc(loc, sc); - exp.e2 = exp.e2.resolveLoc(loc, sc); - if (exp.lowering) - exp.lowering = exp.lowering.resolveLoc(loc, sc); - return exp; - } - - Expression visitStructLiteral(StructLiteralExp exp) - { - if (!exp.elements) - return exp; - - foreach (ref element; *exp.elements) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - return exp; - } - - Expression visitNew(NewExp exp) - { - if (exp.placement) - exp.placement = exp.placement.resolveLoc(loc, sc); - if (exp.thisexp) - exp.thisexp = exp.thisexp.resolveLoc(loc, sc); - if (exp.argprefix) - exp.argprefix = exp.argprefix.resolveLoc(loc, sc); - if (exp.lowering) - exp.lowering = exp.lowering.resolveLoc(loc, sc); - - if (!exp.arguments) - return exp; - - foreach (ref element; *exp.arguments) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - return exp; - } - - Expression visitCall(CallExp exp) - { - if (!exp.arguments) - return exp; - - foreach (ref element; *exp.arguments) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - return exp; - } - - Expression visitArray(ArrayExp exp) - { - exp.e1 = exp.e1.resolveLoc(loc, sc); - - if (!exp.arguments) - return exp; - - foreach (ref element; *exp.arguments) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - return exp; - } - - Expression visitSlice(SliceExp exp) - { - exp.e1 = exp.e1.resolveLoc(loc, sc); - if (exp.lwr) - exp.lwr = exp.lwr.resolveLoc(loc, sc); - if (exp.upr) - exp.upr = exp.upr.resolveLoc(loc, sc); - - return exp; - } - - Expression visitInterval(IntervalExp exp) - { - exp.lwr = exp.lwr.resolveLoc(loc, sc); - exp.upr = exp.upr.resolveLoc(loc, sc); - - return exp; - } - - Expression visitArrayLiteral(ArrayLiteralExp exp) - { - if (exp.basis) - exp.basis = exp.basis.resolveLoc(loc, sc); - - if (exp.elements) - foreach (ref element; *exp.elements) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - if (exp.lowering) - exp.lowering = exp.lowering.resolveLoc(loc, sc); - - return exp; - } - - Expression visitAssocArrayLiteral(AssocArrayLiteralExp exp) - { - foreach (ref element; *exp.keys) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - foreach (ref element; *exp.values) - { - if (element) - element = element.resolveLoc(loc, sc); - } - - if (exp.lowering) - exp.lowering = exp.lowering.resolveLoc(loc, sc); - - return exp; - } - - Expression visitFileInit(FileInitExp exp) - { - //printf("FileInitExp::resolve() %s\n", exp.toErrMsg()); - const(char)* s; - if (exp.op == EXP.fileFullPath) - s = FileName.toAbsolute(loc.isValid() ? loc.filename : sc._module.srcfile.toChars()); - else - s = loc.isValid() ? loc.filename : sc._module.ident.toErrMsg(); - - Expression e = new StringExp(loc, s.toDString()); - return e.expressionSemantic(sc); - } - - Expression visitLineInit(LineInitExp exp) - { - Expression e = new IntegerExp(loc, loc.linnum, Type.tint32); - return e.expressionSemantic(sc); - } - - Expression visitModuleInit(ModuleInitExp exp) - { - const auto s = (sc.callsc ? sc.callsc : sc)._module.toPrettyChars().toDString(); - Expression e = new StringExp(loc, s); - return e.expressionSemantic(sc); - } - - Expression visitFuncInit(FuncInitExp exp) - { - const(char)* s; - if (sc.callsc && sc.callsc.func) - s = sc.callsc.func.Dsymbol.toPrettyChars(); - else if (sc.func) - s = sc.func.Dsymbol.toPrettyChars(); - else - s = ""; - Expression e = new StringExp(loc, s.toDString()); - return e.expressionSemantic(sc); - } - - Expression visitPrettyFunc(PrettyFuncInitExp exp) - { - FuncDeclaration fd = (sc.callsc && sc.callsc.func) - ? sc.callsc.func - : sc.func; - - const(char)* s; - if (fd) - { - const funcStr = fd.Dsymbol.toPrettyChars(); - OutBuffer buf; - functionToBufferWithIdent(fd.type.isTypeFunction(), buf, funcStr, fd.isStatic); - s = buf.extractChars(); - } - else - { - s = ""; - } - - Expression e = new StringExp(loc, s.toDString()); - e = e.expressionSemantic(sc); - e.type = Type.tstring; - return e; - } - - switch(exp.op) - { - default: return visit(exp); - case EXP.structLiteral: return visitStructLiteral(exp.isStructLiteralExp()); - case EXP.new_: return visitNew(exp.isNewExp()); - case EXP.concatenate: return visitCat(exp.isCatExp()); - case EXP.call: return visitCall(exp.isCallExp()); - case EXP.question: return visitCond(exp.isCondExp()); - case EXP.array: return visitArray(exp.isArrayExp()); - case EXP.slice: return visitSlice(exp.isSliceExp()); - case EXP.interval: return visitInterval(exp.isIntervalExp()); - case EXP.arrayLiteral: return visitArrayLiteral(exp.isArrayLiteralExp()); - case EXP.assocArrayLiteral: return visitAssocArrayLiteral(exp.isAssocArrayLiteralExp()); - case EXP.file: - case EXP.fileFullPath: return visitFileInit(exp.isFileInitExp()); - case EXP.line: return visitLineInit(exp.isLineInitExp); - case EXP.moduleString: return visitModuleInit(exp.isModuleInitExp()); - case EXP.functionString: return visitFuncInit(exp.isFuncInitExp()); - case EXP.prettyFunction: return visitPrettyFunc(exp.isPrettyFuncInitExp()); - } -} /************************************************ * Destructors are attached to VarDeclarations. @@ -19812,7 +19610,7 @@ private Expression buildAAIndexRValueX(Type t, Expression eaa, Expression ekey, Expression idrange = new IdentifierExp(loc, Id.empty); idrange = new DotIdExp(loc, idrange, Id.object); idrange = new DotIdExp(loc, idrange, Identifier.idPool("_d_arraybounds")); - auto locargs = new Expressions(new FileInitExp(loc, EXP.file), new LineInitExp(loc)); + auto locargs = new Expressions(new DefaultInitExp(loc, TOK.file), new DefaultInitExp(loc, TOK.line)); auto ex = new CallExp(loc, idrange, locargs); auto ve1 = new VarExp(loc, vardecl); diff --git a/compiler/src/dmd/frontend.h b/compiler/src/dmd/frontend.h index 48bcac12570e..8caab59eb5a7 100644 --- a/compiler/src/dmd/frontend.h +++ b/compiler/src/dmd/frontend.h @@ -274,11 +274,6 @@ class IdentityExp; class CondExp; class GenericExp; class DefaultInitExp; -class FileInitExp; -class LineInitExp; -class ModuleInitExp; -class FuncInitExp; -class PrettyFuncInitExp; class ObjcClassReferenceExp; class ClassReferenceExp; class ThrownExceptionExp; @@ -1400,11 +1395,6 @@ class ParseTimeVisitor virtual void visit(typename AST::ImportExp e); virtual void visit(typename AST::DotTemplateInstanceExp e); virtual void visit(typename AST::ArrayExp e); - virtual void visit(typename AST::FuncInitExp e); - virtual void visit(typename AST::PrettyFuncInitExp e); - virtual void visit(typename AST::FileInitExp e); - virtual void visit(typename AST::LineInitExp e); - virtual void visit(typename AST::ModuleInitExp e); virtual void visit(typename AST::CommaExp e); virtual void visit(typename AST::PostExp e); virtual void visit(typename AST::PowExp e); @@ -2247,25 +2237,20 @@ enum class EXP : uint8_t scope_ = 107u, traits = 108u, overloadSet = 109u, - line = 110u, - file = 111u, - fileFullPath = 112u, - moduleString = 113u, - functionString = 114u, - prettyFunction = 115u, - pow = 116u, - powAssign = 117u, - vector = 118u, - voidExpression = 119u, - cantExpression = 120u, - showCtfeContext = 121u, - objcClassReference = 122u, - vectorArray = 123u, - compoundLiteral = 124u, - _Generic_ = 125u, - interval = 126u, - loweredAssignExp = 127u, - rvalue = 128u, + defaultInit = 110u, + pow = 111u, + powAssign = 112u, + vector = 113u, + voidExpression = 114u, + cantExpression = 115u, + showCtfeContext = 116u, + objcClassReference = 117u, + vectorArray = 118u, + compoundLiteral = 119u, + _Generic_ = 120u, + interval = 121u, + loweredAssignExp = 122u, + rvalue = 123u, }; class Expression : public ASTNode @@ -2414,11 +2399,6 @@ class Expression : public ASTNode CondExp* isCondExp(); GenericExp* isGenericExp(); DefaultInitExp* isDefaultInitExp(); - FileInitExp* isFileInitExp(); - LineInitExp* isLineInitExp(); - ModuleInitExp* isModuleInitExp(); - FuncInitExp* isFuncInitExp(); - PrettyFuncInitExp* isPrettyFuncInitExp(); ObjcClassReferenceExp* isObjcClassReferenceExp(); ClassReferenceExp* isClassReferenceExp(); ThrownExceptionExp* isThrownExceptionExp(); @@ -2721,142 +2701,6 @@ class DeclarationExp final : public Expression void accept(Visitor* v) override; }; -class DefaultInitExp : public Expression -{ -public: - void accept(Visitor* v) override; -}; - -class DelegateExp final : public UnaExp -{ -public: - FuncDeclaration* func; - bool hasOverloads; - VarDeclaration* vthis2; - void accept(Visitor* v) override; -}; - -class DelegateFuncptrExp final : public UnaExp -{ -public: - void accept(Visitor* v) override; -}; - -class DelegatePtrExp final : public UnaExp -{ -public: - void accept(Visitor* v) override; -}; - -class DeleteExp final : public UnaExp -{ -public: - bool isRAII; - void accept(Visitor* v) override; -}; - -class DivAssignExp final : public BinAssignExp -{ -public: - void accept(Visitor* v) override; -}; - -class DivExp final : public BinExp -{ -public: - void accept(Visitor* v) override; -}; - -class IdentifierExp : public Expression -{ -public: - Identifier* ident; - static IdentifierExp* create(Loc loc, Identifier* ident); - void accept(Visitor* v) override; -}; - -class DollarExp final : public IdentifierExp -{ -public: - void accept(Visitor* v) override; -}; - -class DotExp final : public BinExp -{ -public: - void accept(Visitor* v) override; -}; - -class DotIdExp final : public UnaExp -{ -public: - Identifier* ident; - bool noderef; - bool wantsym; - bool arrow; - static DotIdExp* create(Loc loc, Expression* e, Identifier* ident); - void accept(Visitor* v) override; -}; - -class DotTemplateExp final : public UnaExp -{ -public: - TemplateDeclaration* td; - void accept(Visitor* v) override; -}; - -class DotTemplateInstanceExp final : public UnaExp -{ -public: - TemplateInstance* ti; - DotTemplateInstanceExp* syntaxCopy() override; - void accept(Visitor* v) override; -}; - -class DotTypeExp final : public UnaExp -{ -public: - Dsymbol* sym; - void accept(Visitor* v) override; -}; - -class DotVarExp final : public UnaExp -{ -public: - Declaration* var; - bool hasOverloads; - void accept(Visitor* v) override; -}; - -class DsymbolExp final : public Expression -{ -public: - Dsymbol* s; - bool hasOverloads; - void accept(Visitor* v) override; -}; - -class EqualExp final : public BinExp -{ -public: - Expression* lowering; - void accept(Visitor* v) override; -}; - -class ErrorExp final : public Expression -{ -public: - static ErrorExp* get(); - void accept(Visitor* v) override; - static ErrorExp* errorexp; -}; - -class FileInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor* v) override; -}; - enum class TOK : uint8_t { reserved = 0u, @@ -3088,19 +2932,145 @@ enum class TOK : uint8_t __attribute___ = 226u, }; -class FuncExp final : public Expression +class DefaultInitExp : public Expression { public: - FuncLiteralDeclaration* fd; - TemplateDeclaration* td; TOK tok; - FuncExp* syntaxCopy() override; + void accept(Visitor* v) override; + Expression* syntaxCopy() override; +}; + +class DelegateExp final : public UnaExp +{ +public: + FuncDeclaration* func; + bool hasOverloads; + VarDeclaration* vthis2; + void accept(Visitor* v) override; +}; + +class DelegateFuncptrExp final : public UnaExp +{ +public: + void accept(Visitor* v) override; +}; + +class DelegatePtrExp final : public UnaExp +{ +public: + void accept(Visitor* v) override; +}; + +class DeleteExp final : public UnaExp +{ +public: + bool isRAII; + void accept(Visitor* v) override; +}; + +class DivAssignExp final : public BinAssignExp +{ +public: + void accept(Visitor* v) override; +}; + +class DivExp final : public BinExp +{ +public: + void accept(Visitor* v) override; +}; + +class IdentifierExp : public Expression +{ +public: + Identifier* ident; + static IdentifierExp* create(Loc loc, Identifier* ident); + void accept(Visitor* v) override; +}; + +class DollarExp final : public IdentifierExp +{ +public: + void accept(Visitor* v) override; +}; + +class DotExp final : public BinExp +{ +public: + void accept(Visitor* v) override; +}; + +class DotIdExp final : public UnaExp +{ +public: + Identifier* ident; + bool noderef; + bool wantsym; + bool arrow; + static DotIdExp* create(Loc loc, Expression* e, Identifier* ident); void accept(Visitor* v) override; }; -class FuncInitExp final : public DefaultInitExp +class DotTemplateExp final : public UnaExp { public: + TemplateDeclaration* td; + void accept(Visitor* v) override; +}; + +class DotTemplateInstanceExp final : public UnaExp +{ +public: + TemplateInstance* ti; + DotTemplateInstanceExp* syntaxCopy() override; + void accept(Visitor* v) override; +}; + +class DotTypeExp final : public UnaExp +{ +public: + Dsymbol* sym; + void accept(Visitor* v) override; +}; + +class DotVarExp final : public UnaExp +{ +public: + Declaration* var; + bool hasOverloads; + void accept(Visitor* v) override; +}; + +class DsymbolExp final : public Expression +{ +public: + Dsymbol* s; + bool hasOverloads; + void accept(Visitor* v) override; +}; + +class EqualExp final : public BinExp +{ +public: + Expression* lowering; + void accept(Visitor* v) override; +}; + +class ErrorExp final : public Expression +{ +public: + static ErrorExp* get(); + void accept(Visitor* v) override; + static ErrorExp* errorexp; +}; + +class FuncExp final : public Expression +{ +public: + FuncLiteralDeclaration* fd; + TemplateDeclaration* td; + TOK tok; + FuncExp* syntaxCopy() override; void accept(Visitor* v) override; }; @@ -3197,12 +3167,6 @@ class IsExp final : public Expression enum : bool { LOGSEMANTIC = false }; -class LineInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor* v) override; -}; - class LogicalExp final : public BinExp { public: @@ -3248,12 +3212,6 @@ class ModExp final : public BinExp void accept(Visitor* v) override; }; -class ModuleInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor* v) override; -}; - class MulAssignExp final : public BinAssignExp { public: @@ -3364,12 +3322,6 @@ class PreExp final : public UnaExp void accept(Visitor* v) override; }; -class PrettyFuncInitExp final : public DefaultInitExp -{ -public: - void accept(Visitor* v) override; -}; - class PtrExp final : public UnaExp { public: @@ -5534,9 +5486,7 @@ struct ASTCodegen final using EqualExp = ::EqualExp; using ErrorExp = ::ErrorExp; using Expression = ::Expression; - using FileInitExp = ::FileInitExp; using FuncExp = ::FuncExp; - using FuncInitExp = ::FuncInitExp; using GenericExp = ::GenericExp; using HaltExp = ::HaltExp; using IdentifierExp = ::IdentifierExp; @@ -5548,7 +5498,6 @@ struct ASTCodegen final using InterpExp = ::InterpExp; using IntervalExp = ::IntervalExp; using IsExp = ::IsExp; - using LineInitExp = ::LineInitExp; using LogicalExp = ::LogicalExp; using LoweredAssignExp = ::LoweredAssignExp; using MemorySet = ::MemorySet; @@ -5557,7 +5506,6 @@ struct ASTCodegen final using MixinExp = ::MixinExp; using ModAssignExp = ::ModAssignExp; using ModExp = ::ModExp; - using ModuleInitExp = ::ModuleInitExp; using MulAssignExp = ::MulAssignExp; using MulExp = ::MulExp; using NegExp = ::NegExp; @@ -5574,7 +5522,6 @@ struct ASTCodegen final using PowAssignExp = ::PowAssignExp; using PowExp = ::PowExp; using PreExp = ::PreExp; - using PrettyFuncInitExp = ::PrettyFuncInitExp; using PtrExp = ::PtrExp; using RealExp = ::RealExp; using RemoveExp = ::RemoveExp; @@ -6994,6 +6941,7 @@ struct Scope final Statement* scontinue; ForeachStatement* fes; Scope* callsc; + Loc callLoc; Dsymbol* inunion; VarDeclaration* lastVar; ErrorSink* eSink; @@ -7074,6 +7022,7 @@ struct Scope final scontinue(), fes(), callsc(), + callLoc(), inunion(), lastVar(), eSink(), @@ -7097,7 +7046,7 @@ struct Scope final argStruct() { } - Scope(Scope* enclosing, Module* _module = nullptr, ScopeDsymbol* scopesym = nullptr, FuncDeclaration* func = nullptr, VarDeclaration* varDecl = nullptr, Dsymbol* parent = nullptr, LabelStatement* slabel = nullptr, SwitchStatement* switchStatement = nullptr, void* switchCases = nullptr, Statement* tryBody = nullptr, TryFinallyStatement* tryFinally = nullptr, ScopeGuardStatement* scopeGuard = nullptr, Statement* sbreak = nullptr, Statement* scontinue = nullptr, ForeachStatement* fes = nullptr, Scope* callsc = nullptr, Dsymbol* inunion = nullptr, VarDeclaration* lastVar = nullptr, ErrorSink* eSink = nullptr, Module* minst = nullptr, TemplateInstance* tinst = nullptr, CtorFlow ctorflow = CtorFlow(), AlignDeclaration* aligndecl = nullptr, CPPNamespaceDeclaration* namespace_ = nullptr, LINK linkage = (LINK)1u, CPPMANGLE cppmangle = (CPPMANGLE)0u, PragmaDeclaration* inlining = nullptr, Visibility visibility = Visibility((Visibility::Kind)5u, nullptr), STC stc = (STC)0LLU, DeprecatedDeclaration* depdecl = nullptr, uint16_t bitFields = 0u, uint16_t bitFields2 = 0u, Previews previews = Previews(), UserAttributeDeclaration* userAttribDecl = nullptr, void* lastdc = nullptr, void* anchorCounts = nullptr, Identifier* prevAnchor = nullptr, AliasDeclaration* aliasAsg = nullptr, StructDeclaration* argStruct = nullptr) : + Scope(Scope* enclosing, Module* _module = nullptr, ScopeDsymbol* scopesym = nullptr, FuncDeclaration* func = nullptr, VarDeclaration* varDecl = nullptr, Dsymbol* parent = nullptr, LabelStatement* slabel = nullptr, SwitchStatement* switchStatement = nullptr, void* switchCases = nullptr, Statement* tryBody = nullptr, TryFinallyStatement* tryFinally = nullptr, ScopeGuardStatement* scopeGuard = nullptr, Statement* sbreak = nullptr, Statement* scontinue = nullptr, ForeachStatement* fes = nullptr, Scope* callsc = nullptr, Loc callLoc = Loc(), Dsymbol* inunion = nullptr, VarDeclaration* lastVar = nullptr, ErrorSink* eSink = nullptr, Module* minst = nullptr, TemplateInstance* tinst = nullptr, CtorFlow ctorflow = CtorFlow(), AlignDeclaration* aligndecl = nullptr, CPPNamespaceDeclaration* namespace_ = nullptr, LINK linkage = (LINK)1u, CPPMANGLE cppmangle = (CPPMANGLE)0u, PragmaDeclaration* inlining = nullptr, Visibility visibility = Visibility((Visibility::Kind)5u, nullptr), STC stc = (STC)0LLU, DeprecatedDeclaration* depdecl = nullptr, uint16_t bitFields = 0u, uint16_t bitFields2 = 0u, Previews previews = Previews(), UserAttributeDeclaration* userAttribDecl = nullptr, void* lastdc = nullptr, void* anchorCounts = nullptr, Identifier* prevAnchor = nullptr, AliasDeclaration* aliasAsg = nullptr, StructDeclaration* argStruct = nullptr) : enclosing(enclosing), _module(_module), scopesym(scopesym), @@ -7114,6 +7063,7 @@ struct Scope final scontinue(scontinue), fes(fes), callsc(callsc), + callLoc(callLoc), inunion(inunion), lastVar(lastVar), eSink(eSink), @@ -7849,11 +7799,7 @@ class StrictVisitor : public ParseTimeVisitor virtual void visit(typename AST::ImportExp ) override; virtual void visit(typename AST::DotTemplateInstanceExp ) override; virtual void visit(typename AST::ArrayExp ) override; - virtual void visit(typename AST::FuncInitExp ) override; - virtual void visit(typename AST::PrettyFuncInitExp ) override; - virtual void visit(typename AST::FileInitExp ) override; - virtual void visit(typename AST::LineInitExp ) override; - virtual void visit(typename AST::ModuleInitExp ) override; + virtual void visit(typename AST::DefaultInitExp ) override; virtual void visit(typename AST::CommaExp ) override; virtual void visit(typename AST::PostExp ) override; virtual void visit(typename AST::PowExp ) override; diff --git a/compiler/src/dmd/hdrgen.d b/compiler/src/dmd/hdrgen.d index 71e94c2a90cd..7b70304dbf48 100644 --- a/compiler/src/dmd/hdrgen.d +++ b/compiler/src/dmd/hdrgen.d @@ -3056,7 +3056,7 @@ private void expressionPrettyPrint(Expression e, ref OutBuffer buf, ref HdrGenSt void visitDefaultInit(DefaultInitExp e) { - buf.put(EXPtoString(e.op)); + buf.put(Token.toString(e.tok)); } void visitClassReference(ClassReferenceExp e) @@ -4618,12 +4618,7 @@ string EXPtoString(EXP op) EXP.arrayLiteral : "arrayliteral", EXP.assocArrayLiteral : "assocarrayliteral", EXP.classReference : "classreference", - EXP.file : "__FILE__", - EXP.fileFullPath : "__FILE_FULL_PATH__", - EXP.line : "__LINE__", - EXP.moduleString : "__MODULE__", - EXP.functionString : "__FUNCTION__", - EXP.prettyFunction : "__PRETTY_FUNCTION__", + EXP.defaultInit : "defaultinit", EXP.typeid_ : "typeid", EXP.is_ : "is", EXP.assert_ : "assert", diff --git a/compiler/src/dmd/inline.d b/compiler/src/dmd/inline.d index afbb447c1a6a..dc74a2c6ba6b 100644 --- a/compiler/src/dmd/inline.d +++ b/compiler/src/dmd/inline.d @@ -82,44 +82,6 @@ public void inlineScanAllFunctions(Module m, ErrorSink eSink) inlineScanModule(m, PASS.inlineAll, eSink); } -/*********************************************************** - * Perform the "inline copying" of a default argument for a function parameter. - * - * Todo: - * The hack for https://issues.dlang.org/show_bug.cgi?id=4820 case is still questionable. - * Perhaps would have to handle a delegate expression with 'null' context properly in front-end. - */ -public Expression inlineCopy(Expression e, Scope* sc) -{ - /* See https://issues.dlang.org/show_bug.cgi?id=2935 - * for explanation of why just a copy() is broken - */ - //return e.copy(); - if (auto de = e.isDelegateExp()) - { - if (de.func.isNested()) - { - /* https://issues.dlang.org/show_bug.cgi?id=4820 - * Defer checking until later if we actually need the 'this' pointer - */ - return de.copy(); - } - } - const cost = inlineCostExpression(e); - if (cost >= COST_MAX) - { - sc.eSink.error(e.loc, "cannot inline default argument `%s`", e.toErrMsg()); - return ErrorExp.get(); - } - scope ids = new InlineDoState(sc.parent, null); - return doInlineAs!Expression(e, ids); -} - - - - - - private: diff --git a/compiler/src/dmd/parse.d b/compiler/src/dmd/parse.d index ff2f5d913b5e..0da2b83d50ad 100644 --- a/compiler/src/dmd/parse.d +++ b/compiler/src/dmd/parse.d @@ -8278,30 +8278,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer break; case TOK.file: - e = new AST.FileInitExp(loc, EXP.file); - nextToken(); - break; case TOK.fileFullPath: - e = new AST.FileInitExp(loc, EXP.fileFullPath); - nextToken(); - break; - case TOK.line: - e = new AST.LineInitExp(loc); - nextToken(); - break; - case TOK.moduleString: - e = new AST.ModuleInitExp(loc); - nextToken(); - break; case TOK.functionString: - e = new AST.FuncInitExp(loc); - nextToken(); - break; - case TOK.prettyFunction: - e = new AST.PrettyFuncInitExp(loc); + e = new AST.DefaultInitExp(loc, token.value); nextToken(); break; @@ -9793,12 +9775,7 @@ immutable PREC[EXP.max + 1] precedence = EXP.arrayLiteral : PREC.primary, EXP.assocArrayLiteral : PREC.primary, EXP.classReference : PREC.primary, - EXP.file : PREC.primary, - EXP.fileFullPath : PREC.primary, - EXP.line : PREC.primary, - EXP.moduleString : PREC.primary, - EXP.functionString : PREC.primary, - EXP.prettyFunction : PREC.primary, + EXP.defaultInit : PREC.primary, EXP.typeid_ : PREC.primary, EXP.is_ : PREC.primary, EXP.assert_ : PREC.primary, diff --git a/compiler/src/dmd/scope.h b/compiler/src/dmd/scope.h index 1eed50834899..a39ba1c01fd4 100644 --- a/compiler/src/dmd/scope.h +++ b/compiler/src/dmd/scope.h @@ -67,6 +67,7 @@ struct Scope final Statement *scontinue; // enclosing statement that supports "continue" ForeachStatement *fes; // if nested function for ForeachStatement, this is it Scope *callsc; // used for __FUNCTION__, __PRETTY_FUNCTION__ and __MODULE__ + Loc callLoc; // call-site location for __FILE__, __LINE__, and __FILE_FULL_PATH__ Dsymbol *inunion; // !=null if processing members of a union VarDeclaration *lastVar; // Previous symbol used to prevent goto-skips-init ErrorSink *eSink; // sink for error messages diff --git a/compiler/src/dmd/templatesem.d b/compiler/src/dmd/templatesem.d index bd4ec6adef5b..351a622227d0 100644 --- a/compiler/src/dmd/templatesem.d +++ b/compiler/src/dmd/templatesem.d @@ -4087,7 +4087,7 @@ private RootObject defaultArg(TemplateParameter tp, Loc instLoc, Scope* sc) e = e.syntaxCopy(); Scope* sc2 = sc.push(); - sc2.inDefaultArg = true; + sc2.callLoc = instLoc; e = e.expressionSemantic(sc2); sc2.pop(); if (e is null) @@ -4108,7 +4108,6 @@ private RootObject defaultArg(TemplateParameter tp, Loc instLoc, Scope* sc) } if ((e = resolveProperties(sc, e)) is null) return null; - e = e.resolveLoc(instLoc, sc); // use the instantiated loc e = e.optimize(WANTvalue); return e; diff --git a/compiler/src/dmd/tokens.d b/compiler/src/dmd/tokens.d index c1f7b0598749..15a571441beb 100644 --- a/compiler/src/dmd/tokens.d +++ b/compiler/src/dmd/tokens.d @@ -409,12 +409,7 @@ enum EXP : ubyte traits, overloadSet, - line, - file, - fileFullPath, - moduleString, // __MODULE__ - functionString, // __FUNCTION__ - prettyFunction, // __PRETTY_FUNCTION__ + defaultInit, // DefaultInitExp pow, powAssign, vector, diff --git a/compiler/src/dmd/tokens.h b/compiler/src/dmd/tokens.h index 1ce4b24fbffa..0c50aad11d52 100644 --- a/compiler/src/dmd/tokens.h +++ b/compiler/src/dmd/tokens.h @@ -416,12 +416,7 @@ enum class EXP : unsigned char traits, overloadSet, - line, - file, - fileFullPath, - moduleString, // __MODULE__ - functionString, // __FUNCTION__ - prettyFunction, // __PRETTY_FUNCTION__ + defaultInit, pow, powAssign, vector, diff --git a/compiler/src/dmd/visitor.h b/compiler/src/dmd/visitor.h index d359d5174662..1d2895150d75 100644 --- a/compiler/src/dmd/visitor.h +++ b/compiler/src/dmd/visitor.h @@ -293,11 +293,6 @@ class EqualExp; class IdentityExp; class CondExp; class DefaultInitExp; -class FileInitExp; -class LineInitExp; -class ModuleInitExp; -class FuncInitExp; -class PrettyFuncInitExp; class ClassReferenceExp; class VoidInitExp; class ThrownExceptionExp; @@ -526,12 +521,6 @@ class ParseTimeVisitor virtual void visit(DotTemplateInstanceExp *e) { visit((UnaExp *)e); } virtual void visit(ArrayExp *e) { visit((UnaExp *)e); } - // DefaultInitExp - virtual void visit(FuncInitExp *e) { visit((DefaultInitExp *)e); } - virtual void visit(PrettyFuncInitExp *e) { visit((DefaultInitExp *)e); } - virtual void visit(FileInitExp *e) { visit((DefaultInitExp *)e); } - virtual void visit(LineInitExp *e) { visit((DefaultInitExp *)e); } - virtual void visit(ModuleInitExp *e) { visit((DefaultInitExp *)e); } // BinExp virtual void visit(CommaExp *e) { visit((BinExp *)e); } diff --git a/compiler/src/dmd/visitor/parsetime.d b/compiler/src/dmd/visitor/parsetime.d index 914ca413c779..cbf7b1789762 100644 --- a/compiler/src/dmd/visitor/parsetime.d +++ b/compiler/src/dmd/visitor/parsetime.d @@ -228,11 +228,6 @@ public: void visit(AST.ArrayExp e) { visit(cast(AST.UnaExp)e); } // DefaultInitExp - void visit(AST.FuncInitExp e) { visit(cast(AST.DefaultInitExp)e); } - void visit(AST.PrettyFuncInitExp e) { visit(cast(AST.DefaultInitExp)e); } - void visit(AST.FileInitExp e) { visit(cast(AST.DefaultInitExp)e); } - void visit(AST.LineInitExp e) { visit(cast(AST.DefaultInitExp)e); } - void visit(AST.ModuleInitExp e) { visit(cast(AST.DefaultInitExp)e); } // BinExp void visit(AST.CommaExp e) { visit(cast(AST.BinExp)e); } diff --git a/compiler/src/dmd/visitor/strict.d b/compiler/src/dmd/visitor/strict.d index be763df74ab6..8040e5c303fd 100644 --- a/compiler/src/dmd/visitor/strict.d +++ b/compiler/src/dmd/visitor/strict.d @@ -175,11 +175,7 @@ extern(C++) class StrictVisitor(AST) : ParseTimeVisitor!AST override void visit(AST.ImportExp) { assert(0); } override void visit(AST.DotTemplateInstanceExp) { assert(0); } override void visit(AST.ArrayExp) { assert(0); } - override void visit(AST.FuncInitExp) { assert(0); } - override void visit(AST.PrettyFuncInitExp) { assert(0); } - override void visit(AST.FileInitExp) { assert(0); } - override void visit(AST.LineInitExp) { assert(0); } - override void visit(AST.ModuleInitExp) { assert(0); } + override void visit(AST.DefaultInitExp) { assert(0); } override void visit(AST.CommaExp) { assert(0); } override void visit(AST.PostExp) { assert(0); } override void visit(AST.PowExp) { assert(0); }