Skip to content

Commit

Permalink
Merge pull request #4795 from 9rnsr/fix14754
Browse files Browse the repository at this point in the history
[REG2.068b1] Issue 14754 - 64bit wrong code with -inline
  • Loading branch information
WalterBright authored and 9rnsr committed Jul 2, 2015
1 parent aaf5b65 commit 22e27f5
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/e2ir.c
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
69 changes: 56 additions & 13 deletions test/runnable/inline.d
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 @@ -681,6 +723,7 @@ int main()
test11394();
test13503();
test14306();
test14754();
test14606();

printf("Success\n");
Expand Down

0 comments on commit 22e27f5

Please sign in to comment.