Added #warning (suggestion by Rudolf Schubert).
git-svn-id: svn://svn.cc65.org/cc65/trunk@3799 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* */
|
/* */
|
||||||
/* (C) 1998-2005, Ullrich von Bassewitz */
|
/* (C) 1998-2007, Ullrich von Bassewitz */
|
||||||
/* R<EFBFBD>merstra<EFBFBD>e 52 */
|
/* Roemerstrasse 52 */
|
||||||
/* D-70794 Filderstadt */
|
/* D-70794 Filderstadt */
|
||||||
/* EMail: uz@cc65.org */
|
/* EMail: uz@cc65.org */
|
||||||
/* */
|
/* */
|
||||||
@@ -128,7 +128,8 @@ typedef enum {
|
|||||||
PP_INCLUDE,
|
PP_INCLUDE,
|
||||||
PP_LINE,
|
PP_LINE,
|
||||||
PP_PRAGMA,
|
PP_PRAGMA,
|
||||||
PP_UNDEF
|
PP_UNDEF,
|
||||||
|
PP_WARNING,
|
||||||
} pptoken_t;
|
} pptoken_t;
|
||||||
|
|
||||||
|
|
||||||
@@ -150,6 +151,7 @@ static const struct PPToken {
|
|||||||
{ "line", PP_LINE },
|
{ "line", PP_LINE },
|
||||||
{ "pragma", PP_PRAGMA },
|
{ "pragma", PP_PRAGMA },
|
||||||
{ "undef", PP_UNDEF },
|
{ "undef", PP_UNDEF },
|
||||||
|
{ "warning", PP_WARNING },
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Number of preprocessor tokens */
|
/* Number of preprocessor tokens */
|
||||||
@@ -983,19 +985,6 @@ static void PreprocessLine (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DoUndef (void)
|
|
||||||
/* Process the #undef directive */
|
|
||||||
{
|
|
||||||
ident Ident;
|
|
||||||
|
|
||||||
SkipWhitespace ();
|
|
||||||
if (MacName (Ident)) {
|
|
||||||
UndefineMacro (Ident);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int PushIf (int Skip, int Invert, int Cond)
|
static int PushIf (int Skip, int Invert, int Cond)
|
||||||
/* Push a new if level onto the if stack */
|
/* Push a new if level onto the if stack */
|
||||||
{
|
{
|
||||||
@@ -1018,6 +1007,22 @@ static int PushIf (int Skip, int Invert, int Cond)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoError (void)
|
||||||
|
/* Print an error */
|
||||||
|
{
|
||||||
|
SkipWhitespace ();
|
||||||
|
if (CurC == '\0') {
|
||||||
|
PPError ("Invalid #error directive");
|
||||||
|
} else {
|
||||||
|
PPError ("#error: %s", SB_GetConstBuf (Line) + SB_GetIndex (Line));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the rest of line */
|
||||||
|
ClearLine ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int DoIf (int Skip)
|
static int DoIf (int Skip)
|
||||||
/* Process #if directive */
|
/* Process #if directive */
|
||||||
{
|
{
|
||||||
@@ -1162,22 +1167,6 @@ Done:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DoError (void)
|
|
||||||
/* Print an error */
|
|
||||||
{
|
|
||||||
SkipWhitespace ();
|
|
||||||
if (CurC == '\0') {
|
|
||||||
PPError ("Invalid #error directive");
|
|
||||||
} else {
|
|
||||||
PPError ("#error: %s", SB_GetConstBuf (Line) + SB_GetIndex (Line));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clear the rest of line */
|
|
||||||
ClearLine ();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void DoPragma (void)
|
static void DoPragma (void)
|
||||||
/* Handle a #pragma line by converting the #pragma preprocessor directive into
|
/* Handle a #pragma line by converting the #pragma preprocessor directive into
|
||||||
* the _Pragma() compiler operator.
|
* the _Pragma() compiler operator.
|
||||||
@@ -1203,6 +1192,35 @@ static void DoPragma (void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoUndef (void)
|
||||||
|
/* Process the #undef directive */
|
||||||
|
{
|
||||||
|
ident Ident;
|
||||||
|
|
||||||
|
SkipWhitespace ();
|
||||||
|
if (MacName (Ident)) {
|
||||||
|
UndefineMacro (Ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoWarning (void)
|
||||||
|
/* Print a warning */
|
||||||
|
{
|
||||||
|
SkipWhitespace ();
|
||||||
|
if (CurC == '\0') {
|
||||||
|
PPError ("Invalid #warning directive");
|
||||||
|
} else {
|
||||||
|
PPWarning ("#warning: %s", SB_GetConstBuf (Line) + SB_GetIndex (Line));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clear the rest of line */
|
||||||
|
ClearLine ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Preprocess (void)
|
void Preprocess (void)
|
||||||
/* Preprocess a line */
|
/* Preprocess a line */
|
||||||
{
|
{
|
||||||
@@ -1340,6 +1358,18 @@ void Preprocess (void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PP_WARNING:
|
||||||
|
/* #warning is a non standard extension */
|
||||||
|
if (IS_Get (&Standard) > STD_C99) {
|
||||||
|
if (!Skip) {
|
||||||
|
DoWarning ();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PPError ("Preprocessor directive expected");
|
||||||
|
ClearLine ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PPError ("Preprocessor directive expected");
|
PPError ("Preprocessor directive expected");
|
||||||
ClearLine ();
|
ClearLine ();
|
||||||
|
|||||||
Reference in New Issue
Block a user