+2003-12-20 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+ * src/SDCCast.h,
+ * src/SDCCast.c (newAst_),
+ * src/SDCCicode.h,
+ * src/SDCCicode.c (ast2iCode, newiCode),
+ * src/SDCCglobl.h,
+ * src/SDCC.y (logical_and_expr, logical_or_expr, conditional_expr,
+ expr, statement, expression_statement, selection_statement,
+ iteration_statement, expr_opt, jump_statement): foundation for tracking
+ sequence points
+ * src/SDCCopt.c (killDeadCode): fixed bug #861580 (needs the sequence
+ point code too)
+
2003-12-19 Erik Petrich <epetrich@ivorytower.norman.ok.us>
* support/Util/SDCCerr.c,
int blockNo = 0 ; /* sequential block number */
int currBlockno=0 ;
int inCritical= 0 ;
+int seqPointNo= 1 ; /* sequence point number */
extern int yylex();
int yyparse(void);
extern int noLineno ;
logical_and_expr
: inclusive_or_expr
- | logical_and_expr AND_OP inclusive_or_expr
- { $$ = newNode(AND_OP,$1,$3);}
+ | logical_and_expr AND_OP { seqPointNo++;} inclusive_or_expr
+ { $$ = newNode(AND_OP,$1,$4);}
;
logical_or_expr
: logical_and_expr
- | logical_or_expr OR_OP logical_and_expr
- { $$ = newNode(OR_OP,$1,$3); }
+ | logical_or_expr OR_OP { seqPointNo++;} logical_and_expr
+ { $$ = newNode(OR_OP,$1,$4); }
;
conditional_expr
: logical_or_expr
- | logical_or_expr '?' logical_or_expr ':' conditional_expr
+ | logical_or_expr '?' { seqPointNo++;} logical_or_expr ':' conditional_expr
{
- $$ = newNode(':',$3,$5) ;
+ $$ = newNode(':',$4,$6) ;
$$ = newNode('?',$1,$$) ;
}
;
expr
: assignment_expr
- | expr ',' assignment_expr { $$ = newNode(',',$1,$3);}
+ | expr ',' { seqPointNo++;} assignment_expr { $$ = newNode(',',$1,$4);}
;
constant_expr
| jump_statement
| critical_statement
| INLINEASM ';' {
- ast *ex = newNode(INLINEASM,NULL,NULL);
+ ast *ex;
+ seqPointNo++;
+ ex = newNode(INLINEASM,NULL,NULL);
ex->values.inlineasm = strdup($1);
+ seqPointNo++;
$$ = ex;
}
;
expression_statement
: ';' { $$ = NULL;}
- | expr ';'
+ | expr ';' { $$ = $1; seqPointNo++;}
;
else_statement
selection_statement
- : IF '(' expr ')' statement else_statement { noLineno++ ; $$ = createIf ($3, $5, $6 ); noLineno--;}
+ : IF '(' expr ')' { seqPointNo++;} statement else_statement
+ {
+ noLineno++ ;
+ $$ = createIf ($3, $6, $7 );
+ noLineno--;
+ }
| SWITCH '(' expr ')' {
ast *ex ;
static int swLabel = 0 ;
+ seqPointNo++;
/* create a node for expression */
ex = newNode(SWITCH,$3,NULL);
STACK_PUSH(swStk,ex); /* save it in the stack */
;
iteration_statement
- : while '(' expr ')' statement
+ : while '(' expr ')' { seqPointNo++;} statement
{
noLineno++ ;
$$ = createWhile ( $1, STACK_POP(continueStack),
- STACK_POP(breakStack), $3, $5 );
+ STACK_POP(breakStack), $3, $6 );
$$->lineno = $1->lineDef ;
noLineno-- ;
}
| do statement WHILE '(' expr ')' ';'
{
+ seqPointNo++;
noLineno++ ;
$$ = createDo ( $1 , STACK_POP(continueStack),
STACK_POP(breakStack), $5, $2);
;
expr_opt
- : { $$ = NULL ; }
- | expr
+ : { $$ = NULL ; seqPointNo++; }
+ | expr { $$ = $1 ; seqPointNo++; }
;
jump_statement
}
}
| RETURN ';' {
+ seqPointNo++;
if (inCritical) {
werror(E_INVALID_CRITICAL);
$$ = NULL;
}
}
| RETURN expr ';' {
+ seqPointNo++;
if (inCritical) {
werror(E_INVALID_CRITICAL);
$$ = NULL;
int lineno;
int block;
int scopeLevel;
+int seqPoint;
symbol *returnLabel; /* function return label */
symbol *entryLabel; /* function entry label */
ic = Safe_alloc ( sizeof (iCode));
+ ic->seqPoint = seqPoint;
ic->lineno = lineno;
ic->filename = filename;
ic->block = block;
nop->isLiteral = op->isLiteral;
nop->usesDefs = op->usesDefs;
nop->isParm = op->isParm;
-
+
switch (nop->type)
{
case SYMBOL:
block = tree->block;
if (tree->level)
scopeLevel = tree->level;
+ if (tree->seqPoint)
+ seqPoint = tree->seqPoint;
if (tree->type == EX_VALUE)
return operandFromValue (tree->opval.val);