diff --git a/dmd/access.c b/dmd/access.c index 18b4475e..da61b973 100644 --- a/dmd/access.c +++ b/dmd/access.c @@ -257,7 +257,7 @@ halt(); } } -/**************************************** +/**************************************** * Determine if this is the same or friend of cd. */ diff --git a/dmd/cast.c b/dmd/cast.c index 23dee048..6a66cf7e 100644 --- a/dmd/cast.c +++ b/dmd/cast.c @@ -55,8 +55,8 @@ Expression *Expression::implicitCastTo(Scope *sc, Type *t) } else { - warning("%s: implicit conversion of expression (%s) of type %s to %s can cause loss of data", - loc.toChars(), toChars(), type->toChars(), t->toChars()); + warning("implicit conversion of expression (%s) of type %s to %s can cause loss of data", + toChars(), type->toChars(), t->toChars()); } } #if DMDV2 diff --git a/dmd/declaration.h b/dmd/declaration.h index 60dd2d96..f819858f 100644 --- a/dmd/declaration.h +++ b/dmd/declaration.h @@ -634,7 +634,7 @@ struct FuncDeclaration : Declaration void toDocBuffer(OutBuffer *buf); // LDC: give argument types to runtime functions - static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, char *name); + static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, const char *name); static FuncDeclaration *genCfunc(Arguments *args, Type *treturn, Identifier *id); Symbol *toSymbol(); diff --git a/dmd/doc.c b/dmd/doc.c index 9f6e6695..a12f1774 100644 --- a/dmd/doc.c +++ b/dmd/doc.c @@ -17,7 +17,6 @@ #include #include "rmem.h" - #include "root.h" #include "mars.h" diff --git a/dmd/dump.c b/dmd/dump.c index 96b05bcf..1f6fecd1 100644 --- a/dmd/dump.c +++ b/dmd/dump.c @@ -52,7 +52,7 @@ void Expression::dump(int i) void IntegerExp::dump(int i) { indent(i); - printf("%p %lld type=%s\n", this, (long long)value, type_print(type)); + printf("%p %jd type=%s\n", this, (intmax_t)value, type_print(type)); } void IdentifierExp::dump(int i) diff --git a/dmd/expression.c b/dmd/expression.c index a9c23614..62acf04b 100644 --- a/dmd/expression.c +++ b/dmd/expression.c @@ -708,7 +708,6 @@ void functionArguments(Loc loc, Scope *sc, TypeFunction *tf, Expressions *argume } #endif - // Convert lazy argument to a delegate if (p->storageClass & STClazy) { diff --git a/dmd/func.c b/dmd/func.c index 8bc31938..d1930c66 100644 --- a/dmd/func.c +++ b/dmd/func.c @@ -2043,7 +2043,7 @@ int FuncDeclaration::addPostInvariant() // LDC: Adjusted to give argument info to the runtime function decl. // -FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, char *name) +FuncDeclaration *FuncDeclaration::genCfunc(Arguments *args, Type *treturn, const char *name) { return genCfunc(args, treturn, Lexer::idPool(name)); } diff --git a/dmd/init.c b/dmd/init.c index 840485dd..9b058768 100644 --- a/dmd/init.c +++ b/dmd/init.c @@ -384,7 +384,7 @@ Initializer *ArrayInitializer::semantic(Scope *sc, Type *t) } unsigned long amax = 0x80000000; if ((unsigned long) dim * t->next->size() >= amax) - error(loc, "array dimension %u exceeds max of %llu", dim, amax / t->next->size()); + error(loc, "array dimension %u exceeds max of %ju", dim, amax / t->next->size()); return this; } diff --git a/dmd/init.h b/dmd/init.h index 638af67b..77a6b573 100644 --- a/dmd/init.h +++ b/dmd/init.h @@ -26,7 +26,6 @@ struct VoidInitializer; struct StructInitializer; struct ArrayInitializer; struct ExpInitializer; -struct StructInitializer; #ifdef _DH struct HdrGenState; #endif @@ -85,7 +84,7 @@ struct StructInitializer : Initializer dt_t *toDt(); - StructInitializer *isStructInitializer() { return this; } + StructInitializer *isStructInitializer() { return this; } }; struct ArrayInitializer : Initializer diff --git a/dmd/lstring.c b/dmd/lstring.c index 680d60da..b222450e 100644 --- a/dmd/lstring.c +++ b/dmd/lstring.c @@ -14,7 +14,11 @@ #include "rmem.h" #include "lstring.h" +#ifdef _MSC_VER // prevent compiler internal crash +Lstring Lstring::zero; +#else Lstring Lstring::zero = LSTRING_EMPTY(); +#endif Lstring *Lstring::ctor(const dchar *p, unsigned length) { diff --git a/dmd/mangle.c b/dmd/mangle.c index 241119d7..4243697f 100644 --- a/dmd/mangle.c +++ b/dmd/mangle.c @@ -155,11 +155,11 @@ char *FuncDeclaration::mangle() if (isMain()) return (char *)"_Dmain"; - if (isWinMain() || isDllMain()) - return ident->toChars(); + if (isWinMain() || isDllMain()) + return ident->toChars(); - assert(this); - return Declaration::mangle(); + assert(this); + return Declaration::mangle(); } char *StructDeclaration::mangle() diff --git a/dmd/mars.c b/dmd/mars.c index 8837cc01..5df8d985 100644 --- a/dmd/mars.c +++ b/dmd/mars.c @@ -59,7 +59,7 @@ Global::Global() copyright = "Copyright (c) 1999-2009 by Digital Mars and Tomas Lindquist Olsen"; written = "written by Walter Bright and Tomas Lindquist Olsen"; - version = "v1.039"; + version = "v1.041"; ldc_version = LDC_REV; llvm_version = LLVM_REV_STR; global.structalign = 8; diff --git a/dmd/module.c b/dmd/module.c index fac3f413..9eb696fb 100644 --- a/dmd/module.c +++ b/dmd/module.c @@ -16,7 +16,7 @@ #include #endif -#if _MSC_VER || __MINGW32__ +#if defined(_MSC_VER) || defined(__MINGW32__) #include #endif @@ -566,7 +566,7 @@ void Module::parse() } #ifdef IN_GCC - // dump utf-8 encoded source + // dump utf-8 encoded source if (dump_source) { // %% srcname could contain a path ... d_gcc_dump_source(srcname, "utf-8", buf, buflen); diff --git a/dmd/mtype.c b/dmd/mtype.c index d1ad6587..0fd7ec72 100644 --- a/dmd/mtype.c +++ b/dmd/mtype.c @@ -15,7 +15,7 @@ #include #endif -#include +#include #include #include @@ -1741,7 +1741,7 @@ d_uns64 TypeSArray::size(Loc loc) return sz; Loverflow: - error(loc, "index %lld overflow for static array", sz); + error(loc, "index %jd overflow for static array", sz); return 1; } @@ -1809,7 +1809,7 @@ void TypeSArray::resolve(Loc loc, Scope *sc, Expression **pe, Type **pt, Dsymbol sc = sc->pop(); if (d >= td->objects->dim) - { error(loc, "tuple index %llu exceeds %u", d, td->objects->dim); + { error(loc, "tuple index %ju exceeds %u", d, td->objects->dim); goto Ldefault; } Object *o = (Object *)td->objects->data[(size_t)d]; @@ -1863,7 +1863,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc) uinteger_t d = dim->toUInteger(); if (d >= sd->objects->dim) - { error(loc, "tuple index %llu exceeds %u", d, sd->objects->dim); + { error(loc, "tuple index %ju exceeds %u", d, sd->objects->dim); return Type::terror; } Object *o = (Object *)sd->objects->data[(size_t)d]; diff --git a/dmd/opover.c b/dmd/opover.c index 5bd6676e..135420c1 100644 --- a/dmd/opover.c +++ b/dmd/opover.c @@ -12,7 +12,11 @@ #include #include #include +#if _MSC_VER #include +#else +#include +#endif #ifdef __APPLE__ #define integer_t dmd_integer_t diff --git a/dmd/root.h b/dmd/root.h index f2dffbb0..3a4fdf38 100644 --- a/dmd/root.h +++ b/dmd/root.h @@ -38,6 +38,12 @@ void warning(const char *format, ...); #if _MSC_VER #include // for _isnan +#include // for alloca +// According to VC 8.0 docs, long double is the same as double +#define strtold strtod +#define strtof strtod +#define isnan _isnan + typedef __int64 longlong; typedef unsigned __int64 ulonglong; #else diff --git a/dmd/statement.c b/dmd/statement.c index 66c9bf60..f914fc8b 100644 --- a/dmd/statement.c +++ b/dmd/statement.c @@ -1647,7 +1647,6 @@ Statement *ForeachStatement::semantic(Scope *sc) flde->type = fldeTy; } exps->push(flde); - e = new CallExp(loc, ec, exps); e->type = Type::tindex; // don't run semantic() on e } @@ -1712,7 +1711,6 @@ Statement *ForeachStatement::semantic(Scope *sc) flde->type = dgty; } exps->push(flde); - e = new CallExp(loc, ec, exps); e->type = Type::tindex; // don't run semantic() on e } diff --git a/gen/abi-x86-64.cpp b/gen/abi-x86-64.cpp index 933df668..aff42be7 100644 --- a/gen/abi-x86-64.cpp +++ b/gen/abi-x86-64.cpp @@ -400,13 +400,15 @@ namespace x86_64_D_cc { bool retStructInRegs(TypeStruct* st) { // 'fastcc' allows returns in up to two registers of each kind: DRegCount state(2, 2, 2); - #if 1 - // TODO: Disable this if and when LLVM PR 3861 gets fixed. - - // LLVM currently doesn't allow a second int to be an i1 or i8. - // (See ) + #if 1 //LLVM_REV < 67588 + // LLVM before trunk r67588 doesn't allow a second int to be an i1 or + // i8. (See ) // Rather than complicating shouldPassStructInRegs(), just disallow // second integers for now. + // FIXME: Disabling this for older LLVM only makes the abi dependent on + // LLVM revision, which seems like a bad idea. We could extend + // i8 parts to i16 to work around this issue until 2.6... + // TODO: Remove this workaround when support for LLVM 2.5 is dropped. state.ints = 1; #endif return shouldPassStructInRegs(st, state); diff --git a/tests/mini/tuplestruct.d b/tests/mini/tuplestruct.d index debd94b8..b40493c6 100644 --- a/tests/mini/tuplestruct.d +++ b/tests/mini/tuplestruct.d @@ -2,14 +2,14 @@ struct V(T...) { T v; } -alias V!(Object, int) MyV; +alias V!(float, int) MyV; void main() { - assert(MyV.sizeof == Object.sizeof + int.sizeof); - auto o = new Object; - auto v = MyV(o, 3); - assert(v.v[0] is o); + assert(MyV.sizeof == float.sizeof + int.sizeof); + auto f = 3.75f; + auto v = MyV(f, 3); + assert(v.v[0] == 3.75f); assert(v.v[1] == 3); }