Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry-pick commits into stable branch #4804

Merged
merged 3 commits into from
Jul 7, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand All @@ -1101,6 +1095,9 @@ void PragmaDeclaration::semantic(Scope *sc)
}
}
}

if (sc2 != sc)
sc2->pop();
}
return;

Expand Down
2 changes: 1 addition & 1 deletion src/e2ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
21 changes: 18 additions & 3 deletions test/fail_compilation/pragmainline2.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
---
*/

Expand All @@ -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();
}
15 changes: 15 additions & 0 deletions test/runnable/imports/link14588a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module imports.link14588a;

void func(alias a)()
{
}

class A
{
int i;

void all()()
{
func!(i)();
}
}
75 changes: 62 additions & 13 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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

Expand Down Expand Up @@ -658,6 +700,12 @@ void test14606()
auto t = T14606(null);
}

/**********************************/
// 14753

pragma(inline)
void test14753(string) { }

/**********************************/

int main()
Expand All @@ -681,6 +729,7 @@ int main()
test11394();
test13503();
test14306();
test14754();
test14606();

printf("Success\n");
Expand Down
10 changes: 10 additions & 0 deletions test/runnable/link14588.d
Original file line number Diff line number Diff line change
@@ -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();
}