From 4a95e836a667b12ffaef7303aa83b447223e3567 Mon Sep 17 00:00:00 2001 From: Daniel Murphy Date: Wed, 6 Aug 2014 02:10:39 +1000 Subject: [PATCH 1/5] Merge pull request #3847 from 9rnsr/fix13259 [REG2.066a] Issue 13259 - [ICE] 'v.result' on line 191 in file 'todt.c' --- src/todt.c | 1 - test/fail_compilation/ice13259.d | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/fail_compilation/ice13259.d diff --git a/src/todt.c b/src/todt.c index f46f97bddd97..f89d792a190e 100644 --- a/src/todt.c +++ b/src/todt.c @@ -188,7 +188,6 @@ dt_t *Initializer_toDt(Initializer *init) InitToDt v; init->accept(&v); - assert(v.result); return v.result; } diff --git a/test/fail_compilation/ice13259.d b/test/fail_compilation/ice13259.d new file mode 100644 index 000000000000..d6885842e977 --- /dev/null +++ b/test/fail_compilation/ice13259.d @@ -0,0 +1,8 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/ice13259.d(8): Error: non-constant nested delegate literal expression __dgliteral3 +--- +*/ + +auto dg = delegate {}; From 6c6db060de2c1aba316bd92c2dcb44801deafd7f Mon Sep 17 00:00:00 2001 From: Daniel Murphy Date: Wed, 6 Aug 2014 03:22:26 +1000 Subject: [PATCH 2/5] Merge pull request #3846 from 9rnsr/fix13252 [REG2.061] Issue 13252 - ParameterDefaultValueTuple affects other instantiations --- src/expression.c | 12 ++++++++++-- src/template.c | 17 ++++++++--------- test/runnable/template9.d | 27 +++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 11 deletions(-) diff --git a/src/expression.c b/src/expression.c index 2488e2b9d2b0..4475a0bf6649 100644 --- a/src/expression.c +++ b/src/expression.c @@ -3572,8 +3572,11 @@ bool NullExp::equals(RootObject *o) if (o && o->dyncast() == DYNCAST_EXPRESSION) { Expression *e = (Expression *)o; - if (e->op == TOKnull) + if (e->op == TOKnull && + type->equals(e->type)) + { return true; + } } return false; } @@ -4022,6 +4025,11 @@ bool ArrayLiteralExp::equals(RootObject *o) ArrayLiteralExp *ae = (ArrayLiteralExp *)o; if (elements->dim != ae->elements->dim) return false; + if (elements->dim == 0 && + !type->equals(ae->type)) + { + return false; + } for (size_t i = 0; i < elements->dim; i++) { Expression *e1 = (*elements)[i]; @@ -4273,7 +4281,7 @@ bool StructLiteralExp::equals(RootObject *o) ((Expression *)o)->op == TOKstructliteral) { StructLiteralExp *se = (StructLiteralExp *)o; - if (sd != se->sd) + if (!type->equals(se->type)) return false; if (elements->dim != se->elements->dim) return false; diff --git a/src/template.c b/src/template.c index 063a708d4192..84148173474e 100644 --- a/src/template.c +++ b/src/template.c @@ -292,21 +292,20 @@ int match(RootObject *o1, RootObject *o2) { //printf("t1 = %s\n", t1->toChars()); //printf("t2 = %s\n", t2->toChars()); - if (!t2 || !t1->equals(t2)) + if (!t2) + goto Lnomatch; + if (!t1->equals(t2)) goto Lnomatch; } else if (e1) { -#if 0 - if (e1 && e2) - { - printf("match %d\n", e1->equals(e2)); - printf("\te1 = %p %s %s %s\n", e1, e1->type->toChars(), Token::toChars(e1->op), e1->toChars()); - printf("\te2 = %p %s %s %s\n", e2, e2->type->toChars(), Token::toChars(e2->op), e2->toChars()); - } -#endif if (!e2) goto Lnomatch; +#if 0 + printf("match %d\n", e1->equals(e2)); + printf("\te1 = %p %s %s %s\n", e1, e1->type->toChars(), Token::toChars(e1->op), e1->toChars()); + printf("\te2 = %p %s %s %s\n", e2, e2->type->toChars(), Token::toChars(e2->op), e2->toChars()); +#endif if (!e1->equals(e2)) goto Lnomatch; } diff --git a/test/runnable/template9.d b/test/runnable/template9.d index da2cdc7adb21..7ee0a81a38e0 100644 --- a/test/runnable/template9.d +++ b/test/runnable/template9.d @@ -3854,6 +3854,33 @@ void test13223() //static assert(is(typeof(f5(null)) == void[])); } +/******************************************/ +// 13252 + +alias TypeTuple13252(T...) = T; + +static assert(is(typeof(TypeTuple13252!(cast(int )1)[0]) == int )); +static assert(is(typeof(TypeTuple13252!(cast(long)1)[0]) == long)); + +static assert(is(typeof(TypeTuple13252!(cast(float )3.14)[0]) == float )); +static assert(is(typeof(TypeTuple13252!(cast(double)3.14)[0]) == double)); + +static assert(is(typeof(TypeTuple13252!(cast(cfloat )(1 + 2i))[0]) == cfloat )); +static assert(is(typeof(TypeTuple13252!(cast(cdouble)(1 + 2i))[0]) == cdouble)); + +static assert(is(typeof(TypeTuple13252!(cast(string )null)[0]) == string )); +static assert(is(typeof(TypeTuple13252!(cast(string[])null)[0]) == string[])); // OK <- NG + +static assert(is(typeof(TypeTuple13252!(cast(wstring)"abc")[0]) == wstring)); +static assert(is(typeof(TypeTuple13252!(cast(dstring)"abc")[0]) == dstring)); + +static assert(is(typeof(TypeTuple13252!(cast(int[] )[])[0]) == int[] )); +static assert(is(typeof(TypeTuple13252!(cast(long[])[])[0]) == long[])); // OK <- NG + +struct S13252 { } +static assert(is(typeof(TypeTuple13252!(const S13252())[0]) == const(S13252))); +static assert(is(typeof(TypeTuple13252!(immutable S13252())[0]) == immutable(S13252))); // OK <- NG + /******************************************/ int main() From 5f95454a1e5cfe49ffc01d7ac5cb276c6018732e Mon Sep 17 00:00:00 2001 From: Walter Bright Date: Tue, 5 Aug 2014 22:32:06 -0700 Subject: [PATCH 3/5] Merge pull request #3840 from 9rnsr/fix13225 Issue 13225 - [ICE] Access violation on invalid mixin template instantiation --- src/func.c | 6 ++++++ src/mtype.c | 6 ++++-- src/template.c | 22 ++++++---------------- test/compilable/ice13245.d | 5 +++++ test/fail_compilation/ice13225.d | 14 ++++++++++++++ 5 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 test/compilable/ice13245.d create mode 100644 test/fail_compilation/ice13225.d diff --git a/src/func.c b/src/func.c index 93ca8fd3605e..1cac6d0c05c9 100644 --- a/src/func.c +++ b/src/func.c @@ -4492,6 +4492,12 @@ const char *FuncLiteralDeclaration::kind() void FuncLiteralDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) { + if (type->ty == Terror) + { + buf->writestring("__error"); + return; + } + if (tok != TOKreserved) { buf->writestring(kind()); diff --git a/src/mtype.c b/src/mtype.c index e5c365057061..40e009414b13 100644 --- a/src/mtype.c +++ b/src/mtype.c @@ -9609,11 +9609,13 @@ int Parameter::foreach(Parameters *args, Parameter::ForeachDg dg, void *ctx, siz size_t n = pn ? *pn : 0; // take over index int result = 0; for (size_t i = 0; i < args->dim; i++) - { Parameter *arg = (*args)[i]; + { + Parameter *arg = (*args)[i]; Type *t = arg->type->toBasetype(); if (t->ty == Ttuple) - { TypeTuple *tu = (TypeTuple *)t; + { + TypeTuple *tu = (TypeTuple *)t; result = foreach(tu->arguments, dg, ctx, &n); } else diff --git a/src/template.c b/src/template.c index 84148173474e..b1abe2a9e2ec 100644 --- a/src/template.c +++ b/src/template.c @@ -8075,24 +8075,15 @@ void TemplateMixin::semantic(Scope *sc) #endif if (semanticRun != PASSinit) { - // This for when a class/struct contains mixin members, and - // is done over because of forward references - if (parent && toParent()->isAggregateDeclaration()) - { - if (sc->parent != parent) - return; - semanticRun = PASSsemantic; // do over - } - else - { + // When a class/struct contains mixin members, and is done over + // because of forward references, never reach here so semanticRun + // has been reset to PASSinit. #if LOG - printf("\tsemantic done\n"); + printf("\tsemantic done\n"); #endif - return; - } + return; } - if (semanticRun == PASSinit) - semanticRun = PASSsemantic; + semanticRun = PASSsemantic; #if LOG printf("\tdo semantic\n"); #endif @@ -8105,7 +8096,6 @@ void TemplateMixin::semantic(Scope *sc) scope = NULL; } - /* Run semantic on each argument, place results in tiargs[], * then find best match template with tiargs */ diff --git a/test/compilable/ice13245.d b/test/compilable/ice13245.d new file mode 100644 index 000000000000..83ac0fa9eb76 --- /dev/null +++ b/test/compilable/ice13245.d @@ -0,0 +1,5 @@ +// REQUIRED_ARGS: -o- +// PERMUTE_ARGS: + +template T(alias f) {} +static assert(!is(T!( (int x){ return invalid; } ))); diff --git a/test/fail_compilation/ice13225.d b/test/fail_compilation/ice13225.d new file mode 100644 index 000000000000..8582264aca94 --- /dev/null +++ b/test/fail_compilation/ice13225.d @@ -0,0 +1,14 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/ice13225.d(13): Error: undefined identifier undefined +--- +*/ + +mixin template M(T) {} + +struct S +{ + mixin M!((typeof(this)) => 0); + mixin M!(() => undefined); +} From 8631eb8f9748d147f5353dc5585632ff3aa6dabc Mon Sep 17 00:00:00 2001 From: Hara Kenji Date: Wed, 6 Aug 2014 22:47:07 +0900 Subject: [PATCH 4/5] Merge pull request #3848 from WalterBright/fix13237 fix Issue 13237 Wrong code with -inline -O --- src/backend/gother.c | 43 +++++++++++++++++++++++++++++++++++------- test/runnable/test23.d | 17 +++++++++++++++++ 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/src/backend/gother.c b/src/backend/gother.c index ab363cdcefdc..6b2e03243b1c 100644 --- a/src/backend/gother.c +++ b/src/backend/gother.c @@ -921,9 +921,9 @@ void copyprop() /* and the d=b copy elem now reaches the end */ /* of the block (the d=a elem didn't). */ } + if (recalc) + goto Lagain; } - if (recalc) - goto Lagain; } /***************************** @@ -940,6 +940,8 @@ STATIC void cpwalk(register elem *n,vec_t IN) assert(n && IN); /*chkvecdim(exptop,0);*/ + if (recalc) + return; op = n->Eoper; if (op == OPcolon || op == OPcolon2) { @@ -1086,17 +1088,44 @@ STATIC void cpwalk(register elem *n,vec_t IN) } if (foundelem) /* if we can do the copy prop */ { - cmes3("Copyprop, from '%s' to '%s'\n", - (v->Sident) ? (char *)v->Sident : "temp", - (f->Sident) ? (char *)f->Sident : "temp"); - +#ifdef DEBUG + if (debugc) + { + printf("Copyprop, from '%s'(%d) to '%s'(%d)\n", + (v->Sident) ? (char *)v->Sident : "temp", v->Ssymnum, + (f->Sident) ? (char *)f->Sident : "temp", f->Ssymnum); + } +#endif type *nt = n->ET; el_copy(n,foundelem->E2); n->Ety = ty; // retain original type n->ET = nt; + /* original => rewrite + * v = f + * g = v => g = f + * f = x + * d = g => d = f !!error + * Therefore, if g appears as an rvalue in expnod[], then recalc + */ + for (size_t i = 1; i < exptop; ++i) + { + if (expnod[i]->E2 == n) + { + symbol *g = expnod[i]->E1->EV.sp.Vsym; + for (size_t j = 1; j < exptop; ++j) + { + if (expnod[j]->E2->EV.sp.Vsym == g) + { + ++recalc; + break; + } + } + break; + } + } + changes++; - recalc++; } //else dbg_printf("not found\n"); noprop: diff --git a/test/runnable/test23.d b/test/runnable/test23.d index 257aba2e2148..e5e81bafdf4f 100644 --- a/test/runnable/test23.d +++ b/test/runnable/test23.d @@ -1462,6 +1462,22 @@ void test71() /*******************************************/ +size_t getLength(int[] arr) { return arr.length; } + +void test13237() +{ + int[] arr = [0]; + immutable size_t len = getLength(arr); + + arr.length--; + + assert(len == 1); // ok + if (len) { auto l = len; } + assert(len == 1); // len cannot be changed, but produces Assertion failure with "-O -inline" +} + +/*******************************************/ + void main() { test1(); @@ -1528,6 +1544,7 @@ void main() test69(); test70(); test71(); + test13237(); printf("Success\n"); } From a3b6ed697085c8d92b09a2821d353c21cadc68cf Mon Sep 17 00:00:00 2001 From: Andrej Mitrovic Date: Sun, 3 Aug 2014 19:53:47 +0200 Subject: [PATCH 5/5] Merge pull request #3834 from 9rnsr/fix11453 Issue 11453 - Compiling packages has a dependency on order of modules passed to the compiler --- src/module.c | 2 +- test/d_do_test.d | 2 +- test/fail_compilation/extra-files/bar11453.d | 1 + test/fail_compilation/extra-files/foo11453.d | 1 + test/fail_compilation/fail11453a.d | 10 ++++++++++ test/fail_compilation/fail11453b.d | 10 ++++++++++ test/fail_compilation/test64.d | 8 ++++---- 7 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 test/fail_compilation/extra-files/bar11453.d create mode 100644 test/fail_compilation/extra-files/foo11453.d create mode 100644 test/fail_compilation/fail11453a.d create mode 100644 test/fail_compilation/fail11453b.d diff --git a/src/module.c b/src/module.c index a7b5fdd4fc5d..f9a47bc8e342 100644 --- a/src/module.c +++ b/src/module.c @@ -616,7 +616,7 @@ void Module::parse() pkg->mod = this; } else - error(pkg->loc, "from file %s conflicts with package name %s", + error(md ? md->loc : loc, "from file %s conflicts with package name %s", srcname, pkg->toChars()); } else diff --git a/test/d_do_test.d b/test/d_do_test.d index 92e662a12173..ecaffcc20276 100755 --- a/test/d_do_test.d +++ b/test/d_do_test.d @@ -322,7 +322,7 @@ string unifyNewLine(string str) string unifyDirSep(string str, string sep) { - return std.regex.replace(str, regex(`(?<=\w\w*)/(?=\w[\w/]*\.di?\b)`, "g"), sep); + return std.regex.replace(str, regex(`(?<=[-\w][-\w]*)/(?=[-\w][-\w/]*\.di?\b)`, "g"), sep); } unittest { diff --git a/test/fail_compilation/extra-files/bar11453.d b/test/fail_compilation/extra-files/bar11453.d new file mode 100644 index 000000000000..126e0f9c7ef0 --- /dev/null +++ b/test/fail_compilation/extra-files/bar11453.d @@ -0,0 +1 @@ +module foo11453.bar11453; diff --git a/test/fail_compilation/extra-files/foo11453.d b/test/fail_compilation/extra-files/foo11453.d new file mode 100644 index 000000000000..c97e3e1ed30c --- /dev/null +++ b/test/fail_compilation/extra-files/foo11453.d @@ -0,0 +1 @@ +module foo11453; diff --git a/test/fail_compilation/fail11453a.d b/test/fail_compilation/fail11453a.d new file mode 100644 index 000000000000..488bc6e0ff9b --- /dev/null +++ b/test/fail_compilation/fail11453a.d @@ -0,0 +1,10 @@ +// REQUIRED_ARGS: -Ifail_compilation/extra-files +// EXTRA_SOURCES: extra-files/foo11453.d extra-files/bar11453.d +/* +TEST_OUTPUT +--- +fail_compilation/extra-files/bar11453.d(1): Error: package name 'foo11453' conflicts with usage as a module name in file fail_compilation/extra-files/foo11453.d +--- +*/ + +void main() {} diff --git a/test/fail_compilation/fail11453b.d b/test/fail_compilation/fail11453b.d new file mode 100644 index 000000000000..c7bdce5ef830 --- /dev/null +++ b/test/fail_compilation/fail11453b.d @@ -0,0 +1,10 @@ +// REQUIRED_ARGS: -Ifail_compilation/extra-files +// EXTRA_SOURCES: extra-files/bar11453.d extra-files/foo11453.d +/* +TEST_OUTPUT +--- +fail_compilation/extra-files/foo11453.d(1): Error: module foo11453 from file fail_compilation/extra-files/foo11453.d conflicts with package name foo11453 +--- +*/ + +void main() {} diff --git a/test/fail_compilation/test64.d b/test/fail_compilation/test64.d index 204f4e051d14..bfc63f29f121 100644 --- a/test/fail_compilation/test64.d +++ b/test/fail_compilation/test64.d @@ -1,19 +1,19 @@ /* TEST_OUTPUT: --- -Error: module imports from file fail_compilation/imports/test64a.d conflicts with package name imports +fail_compilation/imports/test64a.d(1): Error: module imports from file fail_compilation/imports/test64a.d conflicts with package name imports --- */ // PERMUTE_ARGS: -import std.stdio; +//import std.stdio; import imports.test64a; -int main(char[][] args) +int main(string[] args) { - writefln(file1); + //writefln(file1); return 0; }