Adds the warning diagnositc directive.

This commit is contained in:
John Schneiderman 2024-09-15 10:49:33 +02:00
parent 7abd615a18
commit 7b7fe6c5a9
2 changed files with 19 additions and 0 deletions

View File

@ -144,6 +144,7 @@ const char* TokenNames[] =
"'#ifdef'", "'#ifdef'",
"'#ifndef'", "'#ifndef'",
"'#error'", "'#error'",
"'#warning'",
"'#pragma'", "'#pragma'",
"'#line'", "'#line'",
@ -784,6 +785,19 @@ void Scanner::NextPreToken(void)
} }
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
else if (mToken == TK_PREP_WARN)
{
NextRawToken();
if (mToken == TK_STRING)
{
this->Warning((const char*)mTokenString);
}
else
{
this->Warning("Missing or invalid warning message");
}
}
else if (mToken == TK_PREP_IDENT) else if (mToken == TK_PREP_IDENT)
{ {
Macro* def = nullptr; Macro* def = nullptr;
@ -1166,6 +1180,8 @@ void Scanner::NextSkipRawToken(void)
mToken = TK_PREP_DEFINE; mToken = TK_PREP_DEFINE;
else if (!strcmp(tkprep, "error")) else if (!strcmp(tkprep, "error"))
mToken = TK_PREP_ERROR; mToken = TK_PREP_ERROR;
else if (!strcmp(tkprep, "warning"))
mToken = TK_PREP_WARN;
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"))
@ -1556,6 +1572,8 @@ void Scanner::NextRawToken(void)
mToken = TK_PREP_DEFINE; mToken = TK_PREP_DEFINE;
else if (!strcmp(tkprep, "error")) else if (!strcmp(tkprep, "error"))
mToken = TK_PREP_ERROR; mToken = TK_PREP_ERROR;
else if (!strcmp(tkprep, "warning"))
mToken = TK_PREP_WARN;
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"))

View File

@ -142,6 +142,7 @@ enum Token
TK_PREP_IFDEF, TK_PREP_IFDEF,
TK_PREP_IFNDEF, TK_PREP_IFNDEF,
TK_PREP_ERROR, TK_PREP_ERROR,
TK_PREP_WARN,
TK_PREP_PRAGMA, TK_PREP_PRAGMA,
TK_PREP_LINE, TK_PREP_LINE,