Skip to content

Commit

Permalink
fix Issue 18461 - codegen bug - OPbt expressions and assignments to a…
Browse files Browse the repository at this point in the history
…mbiguous symbols
  • Loading branch information
WalterBright committed Mar 21, 2018
1 parent 54ab04e commit 85251fa
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
16 changes: 13 additions & 3 deletions src/dmd/backend/gflow.c
Expand Up @@ -30,9 +30,12 @@ static char __file__[] = __FILE__; /* for tassert.h */
/* Since many routines are nearly identical, we can combine them with */
/* this flag: */

#define AE 1
#define CP 2
#define VBE 3
enum
{
AE = 1,
CP,
VBE
};

static int flowxx; /* one of the above values */

Expand Down Expand Up @@ -1461,6 +1464,13 @@ STATIC void accumlv(vec_t GEN,vec_t KILL,elem *n)
}
break;

case OPbt: // much like OPind
accumlv(GEN,KILL,n->E1);
accumlv(GEN,KILL,n->E2);
vec_orass(GEN,ambigsym);
vec_subass(GEN,KILL);
break;

case OPind:
case OPucall:
case OPucallns:
Expand Down
6 changes: 6 additions & 0 deletions src/dmd/backend/gother.c
Expand Up @@ -1518,6 +1518,12 @@ STATIC void accumda(elem *n,vec_t DEAD, vec_t POSS)
vec_clearbit(i,POSS);
break;

case OPbt:
accumda(n->E1,DEAD,POSS);
accumda(n->E2,DEAD,POSS);
vec_subass(POSS,ambigref); // remove possibly refed
break;

case OPind:
case OPucall:
case OPucallns:
Expand Down
18 changes: 17 additions & 1 deletion test/runnable/mars1.d
@@ -1,6 +1,6 @@
/*
REQUIRED_ARGS: -mcpu=native -transition=16997 -transition=intpromote
PERMUTE_ARGS: -O -inline
PERMUTE_ARGS: -O -inline -release
*/

import core.stdc.stdio;
Expand Down Expand Up @@ -1736,6 +1736,20 @@ void test18315() // https://issues.dlang.org/show_bug.cgi?id=18315

////////////////////////////////////////////////////////////////////////

// https://issues.dlang.org/show_bug.cgi?id=18461

void test18461()
{
import core.bitop;

size_t test_val = 0b0001_0000;

if (bt(&test_val, 4) == 0)
assert(false);
}

////////////////////////////////////////////////////////////////////////

int main()
{
testgoto();
Expand Down Expand Up @@ -1797,6 +1811,8 @@ int main()
testdivcmp();
test16997();
test18315();
test18461();

printf("Success\n");
return 0;
}

0 comments on commit 85251fa

Please sign in to comment.