Skip to content

Commit

Permalink
kernel/gac: fix CompUnbComObjExpr
Browse files Browse the repository at this point in the history
CompUnbComObjExpr was calling CompSetUseRNam but should not; this lead to the
value of random RNams being emitted to the generated C code.
  • Loading branch information
fingolfin committed Jan 31, 2019
1 parent 2013da1 commit 3327450
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ typedef UInt GVar;
#define COMP_USE_GVAR_COPY (1L << 1)
#define COMP_USE_GVAR_FOPY (1L << 2)

Bag CompInfoGVar;
static Bag CompInfoGVar;

static void CompSetUseGVar(GVar gvar, UInt mode)
{
Expand Down Expand Up @@ -581,7 +581,7 @@ typedef UInt RNam;

#define COMP_USE_RNAM_ID (1L << 0)

Bag CompInfoRNam;
static Bag CompInfoRNam;

static void CompSetUseRNam(RNam rnam, UInt mode)
{
Expand Down Expand Up @@ -4708,7 +4708,7 @@ static void CompUnbRecExpr(Stat stat)
/* compile the record expression */
record = CompExpr(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
/* get the name expression */
rnam = CompExpr(READ_STAT(stat, 1));

/* emit the code for the assignment */
Expand Down Expand Up @@ -4899,9 +4899,8 @@ static void CompUnbComObjExpr(Stat stat)
/* compile the record expression */
record = CompExpr(READ_STAT(stat, 0));

/* get the name (stored immediately in the statement) */
/* get the name expression */
rnam = CompExpr(READ_STAT(stat, 1));
CompSetUseRNam( rnam, COMP_USE_RNAM_ID );

/* emit the code for the assignment */
Emit( "UnbComObj( %c, RNamObj(%c) );\n", record, rnam );
Expand Down
2 changes: 0 additions & 2 deletions tst/test-compile/basics.g.dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ static Obj GF_test__loops;
static GVar G_runtest;

/* record names used in handlers */
static RNam R_WarnOnUnboundGlobals;
static RNam R_myopt;
static RNam R_x;
static RNam R_a;
Expand Down Expand Up @@ -1964,7 +1963,6 @@ static Int PostRestore ( StructInitInfo * module )
G_runtest = GVarName( "runtest" );

/* record names used in handlers */
R_WarnOnUnboundGlobals = RNamName( "WarnOnUnboundGlobals" );
R_myopt = RNamName( "myopt" );
R_x = RNamName( "x" );
R_a = RNamName( "a" );
Expand Down
2 changes: 0 additions & 2 deletions tst/test-compile/basics.g.static.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ static Obj GF_test__loops;
static GVar G_runtest;

/* record names used in handlers */
static RNam R_WarnOnUnboundGlobals;
static RNam R_myopt;
static RNam R_x;
static RNam R_a;
Expand Down Expand Up @@ -1964,7 +1963,6 @@ static Int PostRestore ( StructInitInfo * module )
G_runtest = GVarName( "runtest" );

/* record names used in handlers */
R_WarnOnUnboundGlobals = RNamName( "WarnOnUnboundGlobals" );
R_myopt = RNamName( "myopt" );
R_x = RNamName( "x" );
R_a = RNamName( "a" );
Expand Down

0 comments on commit 3327450

Please sign in to comment.