Merge pull request #1836 from acqn/PPDiag
[cc65] Fixes and improvements for preprocessor diagnostics and error handling
This commit is contained in:
@@ -400,6 +400,11 @@ static void OldStyleComment (void)
|
|||||||
static void NewStyleComment (void)
|
static void NewStyleComment (void)
|
||||||
/* Remove a new style C comment from line. */
|
/* Remove a new style C comment from line. */
|
||||||
{
|
{
|
||||||
|
/* Diagnose if this is unsupported */
|
||||||
|
if (IS_Get (&Standard) < STD_C99) {
|
||||||
|
PPError ("C++ style comments are not allowed in C89");
|
||||||
|
}
|
||||||
|
|
||||||
/* Beware: Because line continuation chars are handled when reading
|
/* Beware: Because line continuation chars are handled when reading
|
||||||
** lines, we may only skip until the end of the source line, which
|
** lines, we may only skip until the end of the source line, which
|
||||||
** may not be the same as the end of the input line. The end of the
|
** may not be the same as the end of the input line. The end of the
|
||||||
@@ -432,7 +437,7 @@ static int SkipWhitespace (int SkipLines)
|
|||||||
} else if (CurC == '/' && NextC == '*') {
|
} else if (CurC == '/' && NextC == '*') {
|
||||||
OldStyleComment ();
|
OldStyleComment ();
|
||||||
Skipped = 1;
|
Skipped = 1;
|
||||||
} else if (IS_Get (&Standard) >= STD_C99 && CurC == '/' && NextC == '/') {
|
} else if (CurC == '/' && NextC == '/') {
|
||||||
NewStyleComment ();
|
NewStyleComment ();
|
||||||
Skipped = 1;
|
Skipped = 1;
|
||||||
} else if (CurC == '\0' && SkipLines) {
|
} else if (CurC == '\0' && SkipLines) {
|
||||||
@@ -1004,6 +1009,7 @@ static void DoDefine (void)
|
|||||||
if (CurC != '.' || NextC != '.') {
|
if (CurC != '.' || NextC != '.') {
|
||||||
PPError ("'...' expected");
|
PPError ("'...' expected");
|
||||||
ClearLine ();
|
ClearLine ();
|
||||||
|
FreeMacro (M);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NextChar ();
|
NextChar ();
|
||||||
@@ -1043,8 +1049,9 @@ static void DoDefine (void)
|
|||||||
|
|
||||||
/* Check for a right paren and eat it if we find one */
|
/* Check for a right paren and eat it if we find one */
|
||||||
if (CurC != ')') {
|
if (CurC != ')') {
|
||||||
PPError ("')' expected");
|
PPError ("')' expected for macro definition");
|
||||||
ClearLine ();
|
ClearLine ();
|
||||||
|
FreeMacro (M);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
NextChar ();
|
NextChar ();
|
||||||
@@ -1558,7 +1565,7 @@ static void TranslationPhase3 (StrBuf* Source, StrBuf* Target)
|
|||||||
} else if (CurC == '/' && NextC == '*') {
|
} else if (CurC == '/' && NextC == '*') {
|
||||||
OldStyleComment ();
|
OldStyleComment ();
|
||||||
HasWhiteSpace = 1;
|
HasWhiteSpace = 1;
|
||||||
} else if (IS_Get (&Standard) >= STD_C99 && CurC == '/' && NextC == '/') {
|
} else if (CurC == '/' && NextC == '/') {
|
||||||
NewStyleComment ();
|
NewStyleComment ();
|
||||||
HasWhiteSpace = 1;
|
HasWhiteSpace = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user