From 357118697d757a7dde4ef0161c209f141a04cd71 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 1 Aug 2008 20:00:23 +0000 Subject: [PATCH] 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 --- src/cc65/stmt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 3e4787ecf..ef150fad5 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -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: -- 2.39.5