diff --git a/src/attrib.c b/src/attrib.c index d9fae94b38f..137362cb46d 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -820,14 +820,6 @@ Scope *PragmaDeclaration::newScope(Scope *sc) inlining = PINLINEnever; } - if (decl) - { - for (size_t i = 0; i < decl->dim; i++) - { - Dsymbol *s = (*decl)[i]; - s->semantic(sc); - } - } return createNewScope(sc, sc->stc, sc->linkage, sc->protection, sc->explicitProtection, sc->structalign, inlining); } return sc; @@ -1080,11 +1072,13 @@ void PragmaDeclaration::semantic(Scope *sc) Ldecl: if (decl) { + Scope *sc2 = newScope(sc); + for (size_t i = 0; i < decl->dim; i++) { Dsymbol *s = (*decl)[i]; - s->semantic(sc); + s->semantic(sc2); if (ident == Id::mangle) { @@ -1101,6 +1095,9 @@ void PragmaDeclaration::semantic(Scope *sc) } } } + + if (sc2 != sc) + sc2->pop(); } return; diff --git a/src/e2ir.c b/src/e2ir.c index 23264ad9bda..2cbb49054f0 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -3363,7 +3363,7 @@ elem *toElem(Expression *e, IRState *irs) if (tb1->ty != Tclass && tb1->ty != Tpointer) e = addressElem(e, tb1); e = el_bin(OPadd, TYnptr, e, el_long(TYsize_t, v->offset)); - if (ISREF(v, tyb)) + if (v->isRef() || v->isOut()) e = el_una(OPind, TYptr, e); e = el_una(OPind, totym(dve->type), e); if (tybasic(e->Ety) == TYstruct) diff --git a/src/template.c b/src/template.c index c65159e744d..c6b45bfa55d 100644 --- a/src/template.c +++ b/src/template.c @@ -7861,10 +7861,10 @@ bool TemplateInstance::needsCodegen() global.params.allInst || global.params.debuglevel) { - //printf("%s minst = %s, enclosing in nonRoot = %d\n", + //printf("%s minst = %s, enclosing (%s)->isNonRoot = %d\n", // toPrettyChars(), minst ? minst->toChars() : NULL, - // enclosing && enclosing->inNonRoot()); - if (enclosing) + // enclosing ? enclosing->toPrettyChars() : NULL, enclosing && enclosing->inNonRoot()); + if (enclosing && !tinst) { // Bugzilla 13415: If and only if the enclosing scope needs codegen, // the nested templates would need code generation. diff --git a/test/fail_compilation/pragmainline2.d b/test/fail_compilation/pragmainline2.d index 49325eac89f..c7b9670b851 100644 --- a/test/fail_compilation/pragmainline2.d +++ b/test/fail_compilation/pragmainline2.d @@ -2,7 +2,9 @@ REQUIRED_ARGS: -inline TEST_OUTPUT: --- -fail_compilation/pragmainline2.d(12): Error: function pragmainline2.foo cannot inline function +fail_compilation/pragmainline2.d(14): Error: function pragmainline2.foo cannot inline function +fail_compilation/pragmainline2.d(22): Error: function pragmainline2.f1t cannot inline function +fail_compilation/pragmainline2.d(25): Error: function pragmainline2.f2t cannot inline function --- */ @@ -13,12 +15,25 @@ void foo() { pragma(inline, false); pragma(inline); - pragma(inline, true); + pragma(inline, true); // this last one will affect to the 'foo' while (0) { } } +pragma(inline, true) void f1t() { while (0) {} } // cannot inline +pragma(inline, false) void f1f() { while (0) {} } +pragma(inline) void f1d() { while (0) {} } +void f2t() { pragma(inline, true); while (0) {} } // cannot inline +void f2f() { pragma(inline, false); while (0) {} } +void f2d() { pragma(inline); while (0) {} } + void main() { foo(); -} + f1t(); + f1f(); + f1d(); + f2t(); + f2f(); + f2d(); +} diff --git a/test/runnable/imports/link14588a.d b/test/runnable/imports/link14588a.d new file mode 100644 index 00000000000..2ea2661de65 --- /dev/null +++ b/test/runnable/imports/link14588a.d @@ -0,0 +1,15 @@ +module imports.link14588a; + +void func(alias a)() +{ +} + +class A +{ + int i; + + void all()() + { + func!(i)(); + } +} diff --git a/test/runnable/inline.d b/test/runnable/inline.d index 571f6eff36a..d540c99f64f 100644 --- a/test/runnable/inline.d +++ b/test/runnable/inline.d @@ -582,13 +582,13 @@ void test14267() } /**********************************/ -// https://issues.dlang.org/show_bug.cgi?id=14306 +// 14306 struct MapResult(alias fun) { void front() { -// while (1) { break; } +// while (1) { break; } fun(1); } } @@ -597,32 +597,74 @@ void bar(R)(R r) { foreach (i; 0..100) { - r.front(); + r.front(); } } -struct S { +struct S +{ int x; - int bump() { - while (1) { break; } - ++x; - return x; + int bump() + { + while (1) { break; } + ++x; + return x; } } -void fun(ref S s) { +void fun(ref S s) +{ MapResult!(y => s.bump())().bar; -// MapResult!((int x) => s.bump())().bar; - +// MapResult!((int x) => s.bump())().bar; - if (s.x != 100) assert(0); + if (s.x != 100) + assert(0); } -void test14306() { +void test14306() +{ S t; fun(t); } +/**********************************/ +// 14754 + +auto aafunc14754(string k) +{ + enum aa = [ "K": "V" ]; + auto p = k in aa; + return null; +} + +struct MapResult14754(alias fun, R) +{ + R _input; + + @property auto ref front() + { + return fun(_input[0]); + } +} + +auto array14754(R)(R r) +{ + alias E = typeof(r.front); + E[] result; + result ~= r.front; + return result; +} + +auto mapfun14754(R)(R words, string k) +{ + return array14754(MapResult14754!(s => aafunc14754(k), R)(words)); +} + +void test14754() +{ + auto r = mapfun14754([""], ""); +} + /**********************************/ // 14606 @@ -658,6 +700,12 @@ void test14606() auto t = T14606(null); } +/**********************************/ +// 14753 + +pragma(inline) +void test14753(string) { } + /**********************************/ int main() @@ -681,6 +729,7 @@ int main() test11394(); test13503(); test14306(); + test14754(); test14606(); printf("Success\n"); diff --git a/test/runnable/link14588.d b/test/runnable/link14588.d new file mode 100644 index 00000000000..2ca4b52f67d --- /dev/null +++ b/test/runnable/link14588.d @@ -0,0 +1,10 @@ +// EXTRA_SOURCES: imports/link14588a.d +// PERMUTE_ARGS: -allinst -unittest -debug -inline +// COMPILE_SEPARATELY + +import imports.link14588a; + +void main() +{ + new A().all(); +}