From a3ca382f0ebdba180b8d8e88fbd92e4b0a06ee95 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Thu, 30 Jan 2014 19:52:17 +0000 Subject: [PATCH 1/3] Unresolved differences between gdc/dmd front ends --- src/ddmd/clone.d | 5 ++++- src/ddmd/cppmangle.d | 13 +++++++++++++ src/ddmd/dcast.d | 8 ++++---- src/ddmd/func.d | 3 ++- src/ddmd/gluelayer.d | 18 ++++++++++++++++++ src/ddmd/id.d | 2 +- src/ddmd/mtype.d | 18 ++++++++++++++++-- 7 files changed, 58 insertions(+), 9 deletions(-) diff --git a/src/ddmd/clone.d b/src/ddmd/clone.d index f86bd583094a..c3bd8d3b01d5 100644 --- a/src/ddmd/clone.d +++ b/src/ddmd/clone.d @@ -636,7 +636,10 @@ extern (C++) FuncDeclaration buildXopCmp(StructDeclaration sd, Scope* sc) fop.generated = true; Expression e1 = new IdentifierExp(loc, Id.p); Expression e2 = new IdentifierExp(loc, Id.q); - Expression e = new CallExp(loc, new DotIdExp(loc, e2, Id.cmp), e1); + static if (IN_GCC) + Expression e = new CallExp(loc, new DotIdExp(loc, e1, Id.cmp), e2); + else + Expression e = new CallExp(loc, new DotIdExp(loc, e2, Id.cmp), e1); fop.fbody = new ReturnStatement(loc, e); uint errors = global.startGagging(); // Do not report errors Scope* sc2 = sc.push(); diff --git a/src/ddmd/cppmangle.d b/src/ddmd/cppmangle.d index 395fe9a9d29e..ae533846a1d1 100644 --- a/src/ddmd/cppmangle.d +++ b/src/ddmd/cppmangle.d @@ -503,6 +503,19 @@ extern (C++) final class CppMangleVisitor : Visitor td = new TypeDelegate(td); t = t.merge(); } + static if (IN_GCC) + { + // Could be a va_list, which we mangle as a pointer. + if (t.ty == Tsarray && Type.tvalist.ty == Tsarray) + { + Type tb = t.toBasetype().mutableOf(); + if (tb == Type.tvalist) + { + tb = t.nextOf().pointerTo(); + t = tb.castMod(t.mod); + } + } + } if (t.ty == Tsarray) { // Mangle static arrays as pointers diff --git a/src/ddmd/dcast.d b/src/ddmd/dcast.d index 4197880c6783..b4fc89ba11b1 100644 --- a/src/ddmd/dcast.d +++ b/src/ddmd/dcast.d @@ -1475,8 +1475,8 @@ extern (C++) Expression castTo(Expression e, Scope* sc, Type t) */ // Fat Value types - const(bool) tob_isFV = (tob.ty == Tstruct || tob.ty == Tsarray); - const(bool) t1b_isFV = (t1b.ty == Tstruct || t1b.ty == Tsarray); + const(bool) tob_isFV = (tob.ty == Tstruct || tob.ty == Tsarray || tob.ty == Tvector); + const(bool) t1b_isFV = (t1b.ty == Tstruct || t1b.ty == Tsarray || t1b.ty == Tvector); // Fat Reference types const(bool) tob_isFR = (tob.ty == Tarray || tob.ty == Tdelegate); @@ -1487,8 +1487,8 @@ extern (C++) Expression castTo(Expression e, Scope* sc, Type t) const(bool) t1b_isR = (t1b_isFR || t1b.ty == Tpointer || t1b.ty == Taarray || t1b.ty == Tclass); // Arithmetic types (== valueable basic types) - const(bool) tob_isA = (tob.isintegral() || tob.isfloating()); - const(bool) t1b_isA = (t1b.isintegral() || t1b.isfloating()); + const(bool) tob_isA = ((tob.isintegral() || tob.isfloating()) && tob.ty != Tvector); + const(bool) t1b_isA = ((t1b.isintegral() || t1b.isfloating()) && t1b.ty != Tvector); if (AggregateDeclaration t1ad = isAggregate(t1b)) { diff --git a/src/ddmd/func.d b/src/ddmd/func.d index 9cea0051c0ea..8c990b6d749c 100644 --- a/src/ddmd/func.d +++ b/src/ddmd/func.d @@ -35,7 +35,6 @@ import ddmd.hdrgen; import ddmd.id; import ddmd.identifier; import ddmd.init; -import ddmd.mars; import ddmd.mtype; import ddmd.nogc; import ddmd.objc; @@ -50,6 +49,8 @@ import ddmd.target; import ddmd.tokens; import ddmd.visitor; +extern (C++) void genCmain(Scope* sc); + /// Inline Status enum ILS : int { diff --git a/src/ddmd/gluelayer.d b/src/ddmd/gluelayer.d index aa1a96f8c7c1..a88256b6b67b 100644 --- a/src/ddmd/gluelayer.d +++ b/src/ddmd/gluelayer.d @@ -53,6 +53,24 @@ version (NoBackend) void objc_initSymbols() {} } } +else version (IN_GCC) +{ + union tree_node; + + alias Symbol = tree_node; + alias code = tree_node; + alias type = tree_node; + + // d-frontend.cc + extern (C++) + { + RET retStyle(TypeFunction tf); + Statement asmSemantic(AsmStatement s, Scope* sc); + } + + // stubs + void objc_initSymbols() { } +} else { import ddmd.lib : Library; diff --git a/src/ddmd/id.d b/src/ddmd/id.d index c60ebc8fdff2..b530760297aa 100644 --- a/src/ddmd/id.d +++ b/src/ddmd/id.d @@ -34,7 +34,7 @@ struct Id * An identifier that corresponds to each static field in this struct will * be placed in the identifier pool. */ - void initialize() + extern (C++) void initialize() { mixin(msgtable.generate(&initializer)); } diff --git a/src/ddmd/mtype.d b/src/ddmd/mtype.d index 71375a439707..edca8afffd8b 100644 --- a/src/ddmd/mtype.d +++ b/src/ddmd/mtype.d @@ -4531,8 +4531,22 @@ extern (C++) final class TypeVector : Type //printf("TypeVector::implicitConvTo(%s) from %s\n", to.toChars(), toChars()); if (this == to) return MATCHexact; - if (ty == to.ty) - return MATCHconvert; + if (to.ty == Tvector) + { + TypeVector tv = cast(TypeVector)to; + assert(basetype.ty == Tsarray && tv.basetype.ty == Tsarray); + + // Can't convert to a vector which has different size. + if (basetype.size() != tv.basetype.size()) + return MATCHnomatch; + + // Allow conversion to void[] + if (tv.basetype.nextOf().ty == Tvoid) + return MATCHconvert; + + // Otherwise implicitly convertible only if basetypes are. + return basetype.implicitConvTo(tv.basetype); + } return MATCHnomatch; } From f662f67ef82fbedf0c602d2e7652083bcf3a8e2f Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Fri, 7 Apr 2017 01:50:54 +0200 Subject: [PATCH 2/3] Add ExtAsmStatement implementation --- src/ddmd/dinterpret.d | 31 ++++ src/ddmd/hdrgen.d | 61 +++++++ src/ddmd/parse.d | 236 ++++++++++++++++++++++++++++ src/ddmd/statement.d | 57 +++++++ src/ddmd/statement.h | 23 +++ src/ddmd/statement_rewrite_walker.d | 8 + src/ddmd/statementsem.d | 65 ++++++++ src/ddmd/visitor.d | 9 ++ src/ddmd/visitor.h | 6 + 9 files changed, 496 insertions(+) diff --git a/src/ddmd/dinterpret.d b/src/ddmd/dinterpret.d index d41ff7616b17..0fa564ac20d0 100644 --- a/src/ddmd/dinterpret.d +++ b/src/ddmd/dinterpret.d @@ -666,6 +666,18 @@ public: // we can't compile asm statements } + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + debug (LOGCOMPILE) + { + printf("%s ExtAsmStatement::ctfeCompile\n", s.loc.toChars()); + } + // we can't compile extended asm statements + } + } + void ctfeCompile(Statement s) { s.accept(this); @@ -1998,6 +2010,25 @@ public: result = CTFEExp.cantexp; } + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + debug (LOG) + { + printf("%s ExtAsmStatement::interpret()\n", s.loc.toChars()); + } + if (istate.start) + { + if (istate.start != s) + return; + istate.start = null; + } + s.error("extended asm statements cannot be interpreted at compile time"); + result = CTFEExp.cantexp; + } + } + override void visit(ImportStatement s) { debug (LOG) diff --git a/src/ddmd/hdrgen.d b/src/ddmd/hdrgen.d index 95743537cb3c..9896128104b3 100644 --- a/src/ddmd/hdrgen.d +++ b/src/ddmd/hdrgen.d @@ -685,6 +685,67 @@ public: buf.writenl(); } + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + buf.writestring ("gcc asm { "); + + if (s.insn) + buf.writestring (s.insn.toChars()); + + buf.writestring (" : "); + + if (s.args) + { + for (size_t i = 0; i < s.args.dim; i++) + { + Identifier name = (*s.names)[i]; + Expression constr = (*s.constraints)[i]; + Expression arg = (*s.args)[i]; + + if (name) + { + buf.writestring ("["); + buf.writestring (name.toChars()); + buf.writestring ("] "); + } + + if (constr) + { + buf.writestring (constr.toChars()); + buf.writestring (" "); + } + + if (arg) + buf.writestring (arg.toChars()); + + if (i < s.outputargs - 1) + buf.writestring (", "); + else if (i == s.outputargs - 1) + buf.writestring (" : "); + else if (i < s.args.dim - 1) + buf.writestring (", "); + } + } + + if (s.clobbers) + { + buf.writestring (" : "); + for (size_t i = 0; i < s.clobbers.dim; i++) + { + Expression clobber = (*s.clobbers)[i]; + buf.writestring (clobber.toChars()); + if (i < s.clobbers.dim - 1) + buf.writestring (", "); + } + } + + buf.writestring ("; }"); + buf.writenl(); + } + } + override void visit(ImportStatement s) { foreach (imp; *s.imports) diff --git a/src/ddmd/parse.d b/src/ddmd/parse.d index b17c91730bb7..76d241303f90 100644 --- a/src/ddmd/parse.d +++ b/src/ddmd/parse.d @@ -5973,6 +5973,20 @@ final class Parser(AST) : Lexer error("matching `}` expected, not end of file"); goto Lerror; + static if (IN_GCC) + { + case TOKlparen: + case TOKstring: + // If the first token is a string or '(', parse as extended asm. + if (!toklist) + { + s = parseExtAsm(stc); + statements.push(s); + continue; + } + goto Ldefault; + } + default: Ldefault: *ptoklist = Token.alloc(); @@ -6019,6 +6033,228 @@ final class Parser(AST) : Lexer return s; } + static if (IN_GCC) + { + /*********************************** + * Parse list of extended asm input or output operands. + * ExtAsmOperand: + * [Identifier] StringLiteral (Identifier), ... + */ + int parseExtAsmOperands(AST.Expressions* args, AST.Identifiers* names, AST.Expressions* constraints) + { + int numargs = 0; + + while (1) + { + AST.Expression arg; + Identifier name; + AST.Expression constraint; + + switch (token.value) + { + case TOKsemicolon: + case TOKcolon: + case TOKeof: + return numargs; + + case TOKlbracket: + nextToken(); + if (token.value == TOKidentifier) + { + name = token.ident; + nextToken(); + } + else + { + error("expected identifier after '['"); + return numargs; + } + check(TOKrbracket); + // fall through + + default: + constraint = parsePrimaryExp(); + if (constraint.op != TOKstring) + { + error(constraint.loc, "expected constant string constraint for operand, not '%s'", constraint.toChars()); + goto Lerror; + } + arg = parseAssignExp(); + + args.push(arg); + names.push(name); + constraints.push(constraint); + numargs++; + + if (token.value == TOKcomma) + nextToken(); + break; + + } + } + Lerror: + while (token.value != TOKrcurly && + token.value != TOKsemicolon && + token.value != TOKeof) + nextToken(); + + return numargs; + } + + /*********************************** + * Parse list of extended asm clobbers. + * ExtAsmClobbers: + * StringLiteral, ... + */ + AST.Expressions *parseExtAsmClobbers() + { + AST.Expressions *clobbers; + + while (1) + { + AST.Expression clobber; + + switch (token.value) + { + case TOKsemicolon: + case TOKcolon: + case TOKeof: + return clobbers; + + case TOKstring: + clobber = parseAssignExp(); + if (!clobbers) + clobbers = new AST.Expressions(); + clobbers.push(clobber); + + if (token.value == TOKcomma) + nextToken(); + break; + + default: + error("expected constant string constraint for clobber name, not '%s'", token.toChars()); + goto Lerror; + } + } + Lerror: + while (token.value != TOKrcurly && + token.value != TOKsemicolon && + token.value != TOKeof) + nextToken(); + + return clobbers; + } + + /*********************************** + * Parse list of extended asm goto labels. + * ExtAsmGotoLabels: + * Identifier, ... + */ + AST.Identifiers *parseExtAsmGotoLabels() + { + AST.Identifiers *labels; + + while (1) + { + switch (token.value) + { + case TOKsemicolon: + case TOKeof: + return labels; + + case TOKidentifier: + if (!labels) + labels = new AST.Identifiers(); + labels.push(token.ident); + + if (nextToken() == TOKcomma) + nextToken(); + break; + + default: + error("expected identifier for goto label name, not '%s'", token.toChars()); + goto Lerror; + } + } + Lerror: + while (token.value != TOKrcurly && + token.value != TOKsemicolon && + token.value != TOKeof) + nextToken(); + + return labels; + } + + /*********************************** + * Parse an extended asm statement. + * ExtAsmStatement: + * asm { StringLiterals [ : InputOperands [ : OutputOperands [ : Clobbers [ : GotoLabels ] ] ] ] } + */ + + AST.Statement parseExtAsm(StorageClass stc) + { + AST.Expressions *args; + AST.Identifiers *names; + AST.Expressions *constraints; + int outputargs = 0; + AST.Expressions *clobbers; + AST.Identifiers *labels; + Loc loc = token.loc; + + AST.Expression insn = parseExpression(); + if (token.value == TOKsemicolon) + goto Ldone; + + for (int section = 0; section < 4; ++section) + { + check(TOKcolon); + + final switch (section) + { + case 0: + if (!args) + { + args = new AST.Expressions(); + constraints = new AST.Expressions(); + names = new AST.Identifiers(); + } + outputargs = parseExtAsmOperands(args, names, constraints); + break; + + case 1: + parseExtAsmOperands(args, names, constraints); + break; + + case 2: + clobbers = parseExtAsmClobbers(); + break; + + case 3: + labels = parseExtAsmGotoLabels(); + break; + } + + switch (token.value) + { + case TOKsemicolon: + goto Ldone; + + case TOKeof: + error("matching '}' expected, not end of file"); + goto Ldone; + + default: + continue; + } + } + Ldone: + check(TOKsemicolon); + + return new AST.ExtAsmStatement(loc, stc, insn, args, names, + constraints, outputargs, clobbers, labels); + } + } + /***************************************** * Parse initializer for variable declaration. */ diff --git a/src/ddmd/statement.d b/src/ddmd/statement.d index 98b7bb356975..ae27389c78ba 100644 --- a/src/ddmd/statement.d +++ b/src/ddmd/statement.d @@ -251,6 +251,14 @@ extern (C++) abstract class Statement : RootObject { stop = true; } + + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + stop = true; + } + } } scope ComeFrom cf = new ComeFrom(); @@ -2436,6 +2444,55 @@ extern (C++) final class AsmStatement : Statement } } +/*********************************************************** + */ +version (IN_GCC) +{ + extern (C++) final class ExtAsmStatement : Statement + { + StorageClass stc; + Expression insn; + Expressions *args; + Identifiers *names; + Expressions *constraints; // Array of StringExp's + uint outputargs; + Expressions *clobbers; // Array of StringExp's + Identifiers *labels; + GotoStatements *gotos; + + extern (D) this(Loc loc, StorageClass stc, Expression insn, + Expressions *args, Identifiers *names, + Expressions *constraints, int outputargs, + Expressions *clobbers, Identifiers *labels) + { + super(loc); + this.insn = insn; + this.args = args; + this.names = names; + this.constraints = constraints; + this.outputargs = outputargs; + this.clobbers = clobbers; + this.labels = labels; + this.gotos = null; + } + + override Statement syntaxCopy() + { + Expressions *c_args = Expression.arraySyntaxCopy(args); + Expressions *c_constraints = Expression.arraySyntaxCopy(constraints); + Expressions *c_clobbers = Expression.arraySyntaxCopy(clobbers); + + return new ExtAsmStatement(loc, stc, insn.syntaxCopy(), c_args, names, + c_constraints, outputargs, c_clobbers, labels); + } + + override void accept(Visitor v) + { + v.visit(this); + } + } +} + /*********************************************************** * a complete asm {} block */ diff --git a/src/ddmd/statement.h b/src/ddmd/statement.h index 06962a1200c7..380e29d9ba8f 100644 --- a/src/ddmd/statement.h +++ b/src/ddmd/statement.h @@ -707,4 +707,27 @@ class ImportStatement : public Statement void accept(Visitor *v) { v->visit(this); } }; +#ifdef IN_GCC + +// Assembler instructions with D expression operands +class ExtAsmStatement : public Statement +{ +public: + StorageClass stc; + Expression *insn; + Expressions *args; + Identifiers *names; + Expressions *constraints; // Array of StringExp's + unsigned outputargs; + Expressions *clobbers; // Array of StringExp's + Identifiers *labels; + GotoStatements *gotos; + + Statement *syntaxCopy(); + + void accept(Visitor *v) { v->visit(this); } +}; + +#endif + #endif /* DMD_STATEMENT_H */ diff --git a/src/ddmd/statement_rewrite_walker.d b/src/ddmd/statement_rewrite_walker.d index 12d36c03dc13..e407acb9543e 100644 --- a/src/ddmd/statement_rewrite_walker.d +++ b/src/ddmd/statement_rewrite_walker.d @@ -14,6 +14,7 @@ module ddmd.statement_rewrite_walker; import core.stdc.stdio; +import ddmd.globals; import ddmd.statement; import ddmd.visitor; @@ -261,6 +262,13 @@ public: { } + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + } + } + override void visit(ImportStatement s) { } diff --git a/src/ddmd/statementsem.d b/src/ddmd/statementsem.d index 22e862843b55..50ec23d8a939 100644 --- a/src/ddmd/statementsem.d +++ b/src/ddmd/statementsem.d @@ -3728,6 +3728,71 @@ else result = asmSemantic(s, sc); } + static if (IN_GCC) + { + override void visit(ExtAsmStatement s) + { + // Fold the instruction template string. + s.insn = s.insn.semantic(sc); + s.insn.ctfeInterpret(); + + if (s.insn.op != TOKstring || (cast(StringExp) s.insn).sz != 1) + s.insn.error("instruction template must be a constant char string"); + + if (s.labels && s.outputargs) + s.error("extended asm statements with labels cannot have output constraints"); + + // Analyse all input and output operands. + if (s.args) + { + for (size_t i = 0; i < s.args.dim; i++) + { + Expression e = (*s.args)[i]; + e = e.semantic(sc); + // Check argument is a valid lvalue/rvalue. + if (i < s.outputargs) + e = e.modifiableLvalue(sc, null); + else if (e.checkValue()) + e = new ErrorExp(); + (*s.args)[i] = e; + + e = (*s.constraints)[i]; + e = e.semantic(sc); + assert(e.op == TOKstring && (cast(StringExp) e).sz == 1); + (*s.constraints)[i] = e; + } + } + + // Analyse all clobbers. + if (s.clobbers) + { + for (size_t i = 0; i < s.clobbers.dim; i++) + { + Expression e = (*s.clobbers)[i]; + e = e.semantic(sc); + assert(e.op == TOKstring && (cast(StringExp) e).sz == 1); + (*s.clobbers)[i] = e; + } + } + + // Analyse all goto labels. + if (s.labels) + { + for (size_t i = 0; i < s.labels.dim; i++) + { + Identifier ident = (*s.labels)[i]; + GotoStatement gs = new GotoStatement(s.loc, ident); + if (!s.gotos) + s.gotos = new GotoStatements(); + s.gotos.push(gs); + semantic(gs, sc); + } + } + + result = s; + } + } + override void visit(CompoundAsmStatement cas) { foreach (ref s; *cas.statements) diff --git a/src/ddmd/visitor.d b/src/ddmd/visitor.d index 181fe4071647..3a9739c4a6c4 100644 --- a/src/ddmd/visitor.d +++ b/src/ddmd/visitor.d @@ -28,6 +28,7 @@ import ddmd.dtemplate; import ddmd.dversion; import ddmd.expression; import ddmd.func; +import ddmd.globals; import ddmd.init; import ddmd.mtype; import ddmd.nspace; @@ -244,6 +245,14 @@ extern (C++) class Visitor visit(cast(Statement)s); } + static if (IN_GCC) + { + void visit(ExtAsmStatement s) + { + visit(cast(Statement)s); + } + } + void visit(CompoundAsmStatement s) { visit(cast(CompoundStatement)s); diff --git a/src/ddmd/visitor.h b/src/ddmd/visitor.h index db8f330fb010..2c986a45645e 100644 --- a/src/ddmd/visitor.h +++ b/src/ddmd/visitor.h @@ -54,6 +54,9 @@ class DebugStatement; class GotoStatement; class LabelStatement; class AsmStatement; +#ifdef IN_GCC +class ExtAsmStatement; +#endif class CompoundAsmStatement; class ImportStatement; @@ -343,6 +346,9 @@ class Visitor virtual void visit(GotoStatement *s) { visit((Statement *)s); } virtual void visit(LabelStatement *s) { visit((Statement *)s); } virtual void visit(AsmStatement *s) { visit((Statement *)s); } +#ifdef IN_GCC + virtual void visit(ExtAsmStatement *s) { visit((Statement *)s); } +#endif virtual void visit(CompoundAsmStatement *s) { visit((CompoundStatement *)s); } virtual void visit(ImportStatement *s) { visit((Statement *)s); } From 8af0aedd652aa6fb4abd6a5dcfe8b2cf61facca6 Mon Sep 17 00:00:00 2001 From: Iain Buclaw Date: Tue, 23 May 2017 10:34:18 +0200 Subject: [PATCH 3/3] Highlight all uses of IN_GCC that have been merged in the frontend. --- src/ddmd/dsymbol.h | 6 +++--- src/ddmd/expression.h | 6 +++--- src/ddmd/globals.d | 2 +- src/ddmd/mtype.d | 4 ++-- src/ddmd/mtype.h | 6 +++--- src/ddmd/statementsem.d | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ddmd/dsymbol.h b/src/ddmd/dsymbol.h index 031355cbdbef..5afd9fd9823a 100644 --- a/src/ddmd/dsymbol.h +++ b/src/ddmd/dsymbol.h @@ -75,11 +75,11 @@ class Expression; class DeleteDeclaration; class OverloadSet; struct AA; -#ifdef IN_GCC +#ifdef IN_GCC // %% typedef union tree_node Symbol; -#else +#else // %% struct Symbol; -#endif +#endif // %% struct Ungag { diff --git a/src/ddmd/expression.h b/src/ddmd/expression.h index 75147c5d1b2d..bd51b2eac9f3 100644 --- a/src/ddmd/expression.h +++ b/src/ddmd/expression.h @@ -49,11 +49,11 @@ class StringExp; class ArrayExp; class SliceExp; struct UnionExp; -#ifdef IN_GCC +#ifdef IN_GCC // %% typedef union tree_node Symbol; -#else +#else // %% struct Symbol; // back end symbol -#endif +#endif // %% Expression *resolveProperties(Scope *sc, Expression *e); Expression *resolvePropertiesOnly(Scope *sc, Expression *e1); diff --git a/src/ddmd/globals.d b/src/ddmd/globals.d index 25ae2c4dd1aa..a832daa35c63 100644 --- a/src/ddmd/globals.d +++ b/src/ddmd/globals.d @@ -23,7 +23,7 @@ template xversion(string s) enum xversion = mixin(`{ version (` ~ s ~ `) return true; else return false; }`)(); } -enum IN_GCC = xversion!`IN_GCC`; +enum IN_GCC = xversion!`IN_GCC`; // %% enum TARGET_LINUX = xversion!`linux`; enum TARGET_OSX = xversion!`OSX`; diff --git a/src/ddmd/mtype.d b/src/ddmd/mtype.d index edca8afffd8b..66d4906bf161 100644 --- a/src/ddmd/mtype.d +++ b/src/ddmd/mtype.d @@ -2863,11 +2863,11 @@ extern (C++) abstract class Type : RootObject assert(0 < length && length < namelen); // don't overflow the buffer int off = 0; - static if (!IN_GCC) + static if (!IN_GCC) // %% { if (global.params.isOSX || global.params.isWindows && !global.params.is64bit) ++off; // C mangling will add '_' back in - } + } // %% auto id = Identifier.idPool(name + off, length - off); if (name != namebuf.ptr) diff --git a/src/ddmd/mtype.h b/src/ddmd/mtype.h index 391ab60a3db1..47a1c36acc8f 100644 --- a/src/ddmd/mtype.h +++ b/src/ddmd/mtype.h @@ -40,11 +40,11 @@ class TypeBasic; class Parameter; // Back end -#ifdef IN_GCC +#ifdef IN_GCC // %% typedef union tree_node type; -#else +#else // %% typedef struct TYPE type; -#endif +#endif // %% void semanticTypeInfo(Scope *sc, Type *t); MATCH deduceType(RootObject *o, Scope *sc, Type *tparam, TemplateParameters *parameters, Objects *dedtypes, unsigned *wm = NULL, size_t inferStart = 0); diff --git a/src/ddmd/statementsem.d b/src/ddmd/statementsem.d index 50ec23d8a939..c4b097fd4410 100644 --- a/src/ddmd/statementsem.d +++ b/src/ddmd/statementsem.d @@ -3572,7 +3572,7 @@ else override void visit(OnScopeStatement oss) { - static if (!IN_GCC) + static if (!IN_GCC) // %% { if (oss.tok != TOKon_scope_exit) { @@ -3591,7 +3591,7 @@ else return setError(); } } - } + } // %% sc = sc.push(); sc.tf = null; @@ -3855,7 +3855,7 @@ void semantic(Catch c, Scope* sc) { //printf("Catch::semantic(%s)\n", ident.toChars()); - static if (!IN_GCC) + static if (!IN_GCC) // %% { if (sc.os && sc.os.tok != TOKon_scope_failure) { @@ -3874,7 +3874,7 @@ void semantic(Catch c, Scope* sc) error(c.loc, "cannot put catch statement inside finally block"); c.errors = true; } - } + } // %% auto sym = new ScopeDsymbol(); sym.parent = sc.scopesym;