Adds support for the error diagnostic directive.
This commit is contained in:
parent
14e5896e37
commit
7abd615a18
|
@ -143,6 +143,7 @@ const char* TokenNames[] =
|
||||||
"'#endif'",
|
"'#endif'",
|
||||||
"'#ifdef'",
|
"'#ifdef'",
|
||||||
"'#ifndef'",
|
"'#ifndef'",
|
||||||
|
"'#error'",
|
||||||
"'#pragma'",
|
"'#pragma'",
|
||||||
"'#line'",
|
"'#line'",
|
||||||
|
|
||||||
|
@ -769,6 +770,20 @@ void Scanner::NextPreToken(void)
|
||||||
mOffset++;
|
mOffset++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mToken == TK_PREP_ERROR)
|
||||||
|
{
|
||||||
|
NextRawToken();
|
||||||
|
|
||||||
|
if (mToken == TK_STRING)
|
||||||
|
{
|
||||||
|
mErrors->Error(mLocation, ERRR_PREPROCESSOR, (const char*)mTokenString);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mErrors->Error(mLocation, EERR_INVALID_PREPROCESSOR, "Missing or invalid error message");
|
||||||
|
}
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
else if (mToken == TK_PREP_IDENT)
|
else if (mToken == TK_PREP_IDENT)
|
||||||
{
|
{
|
||||||
Macro* def = nullptr;
|
Macro* def = nullptr;
|
||||||
|
@ -1149,6 +1164,8 @@ void Scanner::NextSkipRawToken(void)
|
||||||
|
|
||||||
if (!strcmp(tkprep, "define"))
|
if (!strcmp(tkprep, "define"))
|
||||||
mToken = TK_PREP_DEFINE;
|
mToken = TK_PREP_DEFINE;
|
||||||
|
else if (!strcmp(tkprep, "error"))
|
||||||
|
mToken = TK_PREP_ERROR;
|
||||||
else if (!strcmp(tkprep, "undef"))
|
else if (!strcmp(tkprep, "undef"))
|
||||||
mToken = TK_PREP_UNDEF;
|
mToken = TK_PREP_UNDEF;
|
||||||
else if (!strcmp(tkprep, "include"))
|
else if (!strcmp(tkprep, "include"))
|
||||||
|
@ -1537,6 +1554,8 @@ void Scanner::NextRawToken(void)
|
||||||
|
|
||||||
if (!strcmp(tkprep, "define"))
|
if (!strcmp(tkprep, "define"))
|
||||||
mToken = TK_PREP_DEFINE;
|
mToken = TK_PREP_DEFINE;
|
||||||
|
else if (!strcmp(tkprep, "error"))
|
||||||
|
mToken = TK_PREP_ERROR;
|
||||||
else if (!strcmp(tkprep, "undef"))
|
else if (!strcmp(tkprep, "undef"))
|
||||||
mToken = TK_PREP_UNDEF;
|
mToken = TK_PREP_UNDEF;
|
||||||
else if (!strcmp(tkprep, "include"))
|
else if (!strcmp(tkprep, "include"))
|
||||||
|
|
|
@ -141,6 +141,7 @@ enum Token
|
||||||
TK_PREP_ENDIF,
|
TK_PREP_ENDIF,
|
||||||
TK_PREP_IFDEF,
|
TK_PREP_IFDEF,
|
||||||
TK_PREP_IFNDEF,
|
TK_PREP_IFNDEF,
|
||||||
|
TK_PREP_ERROR,
|
||||||
TK_PREP_PRAGMA,
|
TK_PREP_PRAGMA,
|
||||||
TK_PREP_LINE,
|
TK_PREP_LINE,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue