mirror of
https://github.com/cc65/cc65.git
synced 2025-02-06 12:31:12 +00:00
Make the -W flag stackable.
New pragmas codesize, optimize and warn. git-svn-id: svn://svn.cc65.org/cc65/trunk@3130 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
d8279302a9
commit
ca2b070935
@ -6,10 +6,10 @@
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 1998-2000 Ullrich von Bassewitz */
|
||||
/* Wacholderweg 14 */
|
||||
/* D-70597 Stuttgart */
|
||||
/* EMail: uz@musoftware.de */
|
||||
/* (C) 1998-2004 Ullrich von Bassewitz */
|
||||
/* Römerstraße 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
@ -71,7 +71,7 @@ unsigned WarningCount = 0;
|
||||
static void IntWarning (const char* Filename, unsigned Line, const char* Msg, va_list ap)
|
||||
/* Print warning message - internal function. */
|
||||
{
|
||||
if (!NoWarn) {
|
||||
if (!IS_Get (&WarnDisable)) {
|
||||
fprintf (stderr, "%s(%u): Warning: ", Filename, Line);
|
||||
vfprintf (stderr, Msg, ap);
|
||||
fprintf (stderr, "\n");
|
||||
@ -196,7 +196,7 @@ void Internal (const char* Format, ...)
|
||||
|
||||
/* Use abort to create a core dump */
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -47,11 +47,11 @@ unsigned char AddSource = 0; /* Add source lines as comments */
|
||||
unsigned char DebugInfo = 0; /* Add debug info to the obj */
|
||||
unsigned char CreateDep = 0; /* Create a dependency file */
|
||||
unsigned char ANSI = 0; /* Strict ANSI flag */
|
||||
unsigned char NoWarn = 0; /* Suppress warnings */
|
||||
unsigned long OptDisable = 0; /* Optimizer passes to disable */
|
||||
unsigned RegisterSpace = 6; /* Space available for register vars */
|
||||
|
||||
/* Stackable options */
|
||||
IntStack WarnDisable = INTSTACK(0); /* Suppress warnings */
|
||||
IntStack WritableStrings = INTSTACK(0); /* Literal strings are r/w */
|
||||
IntStack InlineStdFuncs = INTSTACK(0); /* Inline some known functions */
|
||||
IntStack EnableRegVars = INTSTACK(0); /* Enable register variables */
|
||||
|
@ -48,16 +48,16 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
extern unsigned char AddSource; /* Add source lines as comments */
|
||||
extern unsigned char DebugInfo; /* Add debug info to the obj */
|
||||
extern unsigned char CreateDep; /* Create a dependency file */
|
||||
extern unsigned char ANSI; /* Strict ANSI flag */
|
||||
extern unsigned char NoWarn; /* Suppress warnings */
|
||||
extern unsigned long OptDisable; /* Optimizer passes to disable */
|
||||
extern unsigned RegisterSpace; /* Space available for register vars */
|
||||
|
||||
/* Stackable options */
|
||||
extern IntStack WarnDisable; /* Suppress warnings */
|
||||
extern IntStack WritableStrings; /* Literal strings are r/w */
|
||||
extern IntStack InlineStdFuncs; /* Inline some known functions */
|
||||
extern IntStack EnableRegVars; /* Enable register variables */
|
||||
|
@ -833,7 +833,7 @@ int main (int argc, char* argv[])
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
NoWarn = 1;
|
||||
IS_Set (&WarnDisable, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -66,12 +66,15 @@ typedef enum {
|
||||
PR_CHARMAP,
|
||||
PR_CHECKSTACK,
|
||||
PR_CODESEG,
|
||||
PR_CODESIZE,
|
||||
PR_DATASEG,
|
||||
PR_OPTIMIZE,
|
||||
PR_REGVARADDR,
|
||||
PR_REGVARS,
|
||||
PR_RODATASEG,
|
||||
PR_SIGNEDCHARS,
|
||||
PR_STATICLOCALS,
|
||||
PR_WARN,
|
||||
PR_ZPSYM,
|
||||
PR_COUNT
|
||||
} pragma_t;
|
||||
@ -85,12 +88,15 @@ static const struct Pragma {
|
||||
{ "charmap", PR_CHARMAP },
|
||||
{ "checkstack", PR_CHECKSTACK },
|
||||
{ "codeseg", PR_CODESEG },
|
||||
{ "codesize", PR_CODESIZE },
|
||||
{ "dataseg", PR_DATASEG },
|
||||
{ "optimize", PR_OPTIMIZE },
|
||||
{ "regvaraddr", PR_REGVARADDR },
|
||||
{ "regvars", PR_REGVARS },
|
||||
{ "rodataseg", PR_RODATASEG },
|
||||
{ "signedchars", PR_SIGNEDCHARS },
|
||||
{ "staticlocals", PR_STATICLOCALS },
|
||||
{ "warn", PR_WARN },
|
||||
{ "zpsym", PR_ZPSYM },
|
||||
};
|
||||
|
||||
@ -214,7 +220,7 @@ static void SegNamePragma (StrBuf* B, segment_t Seg)
|
||||
} else {
|
||||
SetSegName (Seg, Name);
|
||||
}
|
||||
g_segname (Seg);
|
||||
g_segname (Seg);
|
||||
|
||||
/* Call the string buf destructor */
|
||||
DoneStrBuf (&S);
|
||||
@ -322,6 +328,67 @@ static void FlagPragma (StrBuf* B, IntStack* Stack)
|
||||
|
||||
|
||||
|
||||
static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
|
||||
/* Handle a pragma that expects an int paramater */
|
||||
{
|
||||
ident Ident;
|
||||
long Val;
|
||||
int Push;
|
||||
|
||||
/* Try to read an identifier */
|
||||
int IsIdent = SB_GetSym (B, Ident);
|
||||
|
||||
/* Check if we have a first argument named "pop" */
|
||||
if (IsIdent && strcmp (Ident, "pop") == 0) {
|
||||
if (IS_GetCount (Stack) < 2) {
|
||||
Error ("Cannot pop, stack is empty");
|
||||
} else {
|
||||
IS_Drop (Stack);
|
||||
}
|
||||
/* No other arguments allowed */
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check if we have a first argument named "push" */
|
||||
if (IsIdent && strcmp (Ident, "push") == 0) {
|
||||
Push = 1;
|
||||
SB_SkipWhite (B);
|
||||
if (SB_Get (B) != ',') {
|
||||
Error ("Comma expected");
|
||||
return;
|
||||
}
|
||||
SB_SkipWhite (B);
|
||||
IsIdent = 0;
|
||||
} else {
|
||||
Push = 0;
|
||||
}
|
||||
|
||||
/* Integer argument follows */
|
||||
if (IsIdent || !SB_GetNumber (B, &Val)) {
|
||||
Error ("Pragma argument must be numeric");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check the argument */
|
||||
if (Val < Low || Val > High) {
|
||||
Error ("Pragma argument out of bounds (%ld-%ld)", Low, High);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Set/push the new value */
|
||||
if (Push) {
|
||||
if (IS_IsFull (Stack)) {
|
||||
Error ("Cannot push: stack overflow");
|
||||
} else {
|
||||
IS_Push (Stack, Val);
|
||||
}
|
||||
} else {
|
||||
IS_Set (Stack, Val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ParsePragma (void)
|
||||
/* Parse the contents of the _Pragma statement */
|
||||
{
|
||||
@ -391,10 +458,18 @@ static void ParsePragma (void)
|
||||
SegNamePragma (&B, SEG_CODE);
|
||||
break;
|
||||
|
||||
case PR_CODESIZE:
|
||||
IntPragma (&B, &CodeSizeFactor, 10, 1000);
|
||||
break;
|
||||
|
||||
case PR_DATASEG:
|
||||
SegNamePragma (&B, SEG_DATA);
|
||||
break;
|
||||
|
||||
case PR_OPTIMIZE:
|
||||
FlagPragma (&B, &Optimize);
|
||||
break;
|
||||
|
||||
case PR_REGVARADDR:
|
||||
FlagPragma (&B, &AllowRegVarAddr);
|
||||
break;
|
||||
@ -415,7 +490,11 @@ static void ParsePragma (void)
|
||||
FlagPragma (&B, &StaticLocals);
|
||||
break;
|
||||
|
||||
case PR_ZPSYM:
|
||||
case PR_WARN:
|
||||
FlagPragma (&B, &WarnDisable);
|
||||
break;
|
||||
|
||||
case PR_ZPSYM:
|
||||
StringPragma (&B, MakeZPSym);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user