1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 17:30:50 +00:00

Fixed parsing a labeled-statement: A label is always part of a statement, it

is not itself one.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4166 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-09-13 14:36:16 +00:00
parent fe652c8206
commit 32e2eb3fad

View File

@ -544,101 +544,100 @@ int Statement (int* PendingToken)
*PendingToken = 0; *PendingToken = 0;
} }
/* Check for a label */ /* Check for a label. A label is always part of a statement, it does not
if (CurTok.Tok == TOK_IDENT && NextTok.Tok == TOK_COLON) { * replace one.
*/
/* Special handling for a label */ while (CurTok.Tok == TOK_IDENT && NextTok.Tok == TOK_COLON) {
/* Handle the label */
DoLabel (); DoLabel ();
CheckLabelWithoutStatement (); CheckLabelWithoutStatement ();
}
} else { switch (CurTok.Tok) {
switch (CurTok.Tok) { case TOK_LCURLY:
NextToken ();
GotBreak = CompoundStatement ();
CheckTok (TOK_RCURLY, "`{' expected", PendingToken);
return GotBreak;
case TOK_LCURLY: case TOK_IF:
NextToken (); return IfStatement ();
GotBreak = CompoundStatement ();
CheckTok (TOK_RCURLY, "`{' expected", PendingToken);
return GotBreak;
case TOK_IF: case TOK_WHILE:
return IfStatement (); WhileStatement ();
break;
case TOK_WHILE: case TOK_DO:
WhileStatement (); DoStatement ();
break; break;
case TOK_DO: case TOK_SWITCH:
DoStatement (); SwitchStatement ();
break; break;
case TOK_SWITCH: case TOK_RETURN:
SwitchStatement (); ReturnStatement ();
break; CheckSemi (PendingToken);
return 1;
case TOK_RETURN: case TOK_BREAK:
ReturnStatement (); BreakStatement ();
CheckSemi (PendingToken); CheckSemi (PendingToken);
return 1; return 1;
case TOK_BREAK: case TOK_CONTINUE:
BreakStatement (); ContinueStatement ();
CheckSemi (PendingToken); CheckSemi (PendingToken);
return 1; return 1;
case TOK_CONTINUE: case TOK_FOR:
ContinueStatement (); ForStatement ();
CheckSemi (PendingToken); break;
return 1;
case TOK_FOR: case TOK_GOTO:
ForStatement (); GotoStatement ();
break; CheckSemi (PendingToken);
return 1;
case TOK_GOTO: case TOK_SEMI:
GotoStatement (); /* Ignore it */
CheckSemi (PendingToken); CheckSemi (PendingToken);
return 1; break;
case TOK_SEMI: case TOK_PRAGMA:
/* Ignore it */ DoPragma ();
CheckSemi (PendingToken); break;
break;
case TOK_PRAGMA: case TOK_CASE:
DoPragma (); CaseLabel ();
break; CheckLabelWithoutStatement ();
break;
case TOK_CASE: case TOK_DEFAULT:
CaseLabel (); DefaultLabel ();
CheckLabelWithoutStatement (); CheckLabelWithoutStatement ();
break; break;
case TOK_DEFAULT: default:
DefaultLabel (); /* Remember the current code position */
CheckLabelWithoutStatement (); GetCodePos (&Start);
break; /* Actual statement */
ExprWithCheck (hie0, &Expr);
default: /* Load the result only if it is an lvalue and the type is
/* Remember the current code position */ * marked as volatile. Otherwise the load is useless.
GetCodePos (&Start); */
/* Actual statement */ if (ED_IsLVal (&Expr) && IsQualVolatile (Expr.Type)) {
ExprWithCheck (hie0, &Expr); LoadExpr (CF_NONE, &Expr);
/* Load the result only if it is an lvalue and the type is }
* marked as volatile. Otherwise the load is useless. /* If the statement didn't generate code, and is not of type
*/ * void, emit a warning.
if (ED_IsLVal (&Expr) && IsQualVolatile (Expr.Type)) { */
LoadExpr (CF_NONE, &Expr); GetCodePos (&End);
} if (CodeRangeIsEmpty (&Start, &End) && !IsTypeVoid (Expr.Type)) {
/* If the statement didn't generate code, and is not of type Warning ("Statement has no effect");
* void, emit a warning. }
*/ CheckSemi (PendingToken);
GetCodePos (&End);
if (CodeRangeIsEmpty (&Start, &End) && !IsTypeVoid (Expr.Type)) {
Warning ("Statement has no effect");
}
CheckSemi (PendingToken);
}
} }
return 0; return 0;
} }