mirror of
https://github.com/cc65/cc65.git
synced 2024-11-19 21:32:19 +00:00
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:
parent
0b4a94a65e
commit
79a89299b9
@ -6,8 +6,8 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2005, Ullrich von Bassewitz */
|
||||
/* Römerstraße 52 */
|
||||
/* (C) 1998-2007, Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
@ -128,7 +128,8 @@ typedef enum {
|
||||
PP_INCLUDE,
|
||||
PP_LINE,
|
||||
PP_PRAGMA,
|
||||
PP_UNDEF
|
||||
PP_UNDEF,
|
||||
PP_WARNING,
|
||||
} pptoken_t;
|
||||
|
||||
|
||||
@ -150,6 +151,7 @@ static const struct PPToken {
|
||||
{ "line", PP_LINE },
|
||||
{ "pragma", PP_PRAGMA },
|
||||
{ "undef", PP_UNDEF },
|
||||
{ "warning", PP_WARNING },
|
||||
};
|
||||
|
||||
/* 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)
|
||||
/* 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)
|
||||
/* 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)
|
||||
/* Handle a #pragma line by converting the #pragma preprocessor directive into
|
||||
* 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)
|
||||
/* Preprocess a line */
|
||||
{
|
||||
@ -1340,6 +1358,18 @@ void Preprocess (void)
|
||||
}
|
||||
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:
|
||||
PPError ("Preprocessor directive expected");
|
||||
ClearLine ();
|
||||
|
Loading…
Reference in New Issue
Block a user