1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-24 11:31:31 +00:00

A label must always be followed by a statement. Check for this.

git-svn-id: svn://svn.cc65.org/cc65/trunk@3860 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2008-08-01 20:00:23 +00:00
parent 64ec376140
commit 357118697d

View File

@ -71,6 +71,19 @@
static void CheckLabelWithoutStatement (void)
/* Called from Statement() after a label definition. Will check for a
* following closing curly brace. This means that a label is not followed
* by a statement which is required by the standard. Output an error if so.
*/
{
if (CurTok.Tok == TOK_RCURLY) {
Error ("Label at end of compound statement");
}
}
static void CheckTok (token_t Tok, const char* Msg, int* PendingToken)
/* Helper function for Statement. Will check for Tok and print Msg if not
* found. If PendingToken is NULL, it will the skip the token, otherwise
@ -534,6 +547,7 @@ int Statement (int* PendingToken)
/* Special handling for a label */
DoLabel ();
CheckLabelWithoutStatement ();
} else {
@ -595,10 +609,12 @@ int Statement (int* PendingToken)
case TOK_CASE:
CaseLabel ();
CheckLabelWithoutStatement ();
break;
case TOK_DEFAULT:
DefaultLabel ();
CheckLabelWithoutStatement ();
break;
default: