From: tecodev Date: Wed, 9 Feb 2005 14:59:40 +0000 (+0000) Subject: * src/SDCC.lex(doPragma) : save and restore warning options as well X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=1037293c11a3f73193c9f25e3eb207ce17b751ae;p=fw%2Fsdcc * src/SDCC.lex(doPragma) : save and restore warning options as well (also added new stack plus clone- and copyAndFreeSDCCERRG()) * have #pragma less_pedantic set the errorlevel to WARNING (fixes #1117001) * (cloneOptimize) : fixed wrong malloc's size * support/Util/SDCCerr.[ch] : made SDCCERRG globally accessible to facilitate correct handling of #pragma (save|restore) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3674 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 0e23e3dc..47b13e89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ -2004-02-03 Maarten Brock +2005-02-09 Raphael Neider + + * src/SDCC.lex(doPragma) : save and restore warning options as well + (also added new stack plus clone- and copyAndFreeSDCCERRG()) + * have #pragma less_pedantic set the errorlevel to WARNING + (fixes #1117001) + * (cloneOptimize) : fixed wrong malloc's size + * support/Util/SDCCerr.[ch] : made SDCCERRG globally accessible to + facilitate correct handling of #pragma (save|restore) + +2005-02-09 Maarten Brock * src/mcs51/gen.c: removed non-standard C nameless struct/union diff --git a/src/SDCC.lex b/src/SDCC.lex index 60820b75..1701dbe1 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -430,6 +430,7 @@ enum pragma_id { STACK_DCL(options_stack, struct options *, SAVE_RESTORE_SIZE) STACK_DCL(optimize_stack, struct optimize *, SAVE_RESTORE_SIZE) +STACK_DCL(SDCCERRG_stack, struct SDCCERRG *, SAVE_RESTORE_SIZE) /* * cloneXxx functions should be updated every time a new set is @@ -458,7 +459,7 @@ static struct optimize *cloneOptimize(struct optimize *opt) { struct optimize *new_opt; - new_opt = Safe_malloc(sizeof (struct options)); + new_opt = Safe_malloc(sizeof (struct optimize)); /* clone scalar values */ *new_opt = *opt; @@ -466,6 +467,18 @@ static struct optimize *cloneOptimize(struct optimize *opt) return new_opt; } +static struct SDCCERRG *cloneSDCCERRG (struct SDCCERRG *val) +{ + struct SDCCERRG *new_val; + + new_val = Safe_malloc(sizeof (struct SDCCERRG)); + + /* clone scalar values */ + *new_val = *val; + + return new_val; +} + static void copyAndFreeOptions(struct options *dest, struct options *src) { /* delete dest sets */ @@ -474,7 +487,7 @@ static void copyAndFreeOptions(struct options *dest, struct options *src) /* not implemented yet: */ /* deleteSet(&dest->olaysSet); */ - /* dopy src to dest */ + /* copy src to dest */ *dest = *src; Safe_free(src); @@ -482,7 +495,15 @@ static void copyAndFreeOptions(struct options *dest, struct options *src) static void copyAndFreeOptimize(struct optimize *dest, struct optimize *src) { - /* dopy src to dest */ + /* copy src to dest */ + *dest = *src; + + Safe_free(src); +} + +static void copyAndFreeSDCCERRG(struct SDCCERRG *dest, struct SDCCERRG *src) +{ + /* copy src to dest */ *dest = *src; Safe_free(src); @@ -497,6 +518,7 @@ static void doPragma(int op, char *cp) { STACK_PUSH(options_stack, cloneOptions(&options)); STACK_PUSH(optimize_stack, cloneOptimize(&optimize)); + STACK_PUSH(SDCCERRG_stack, cloneSDCCERRG(&_SDCCERRG)); } break; @@ -504,12 +526,16 @@ static void doPragma(int op, char *cp) { struct options *optionsp; struct optimize *optimizep; + struct SDCCERRG *sdccerrgp; optionsp = STACK_POP(options_stack); copyAndFreeOptions(&options, optionsp); optimizep = STACK_POP(optimize_stack); copyAndFreeOptimize(&optimize, optimizep); + + sdccerrgp = STACK_POP(SDCCERRG_stack); + copyAndFreeSDCCERRG(&_SDCCERRG, sdccerrgp); } break; @@ -543,6 +569,7 @@ static void doPragma(int op, char *cp) case P_LESSPEDANTIC: options.lessPedantic = 1; + setErrorLogLevel(ERROR_LEVEL_WARNING); break; case P_CALLEE_SAVES: diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 6542a7ea..19594964 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -29,12 +29,7 @@ #define DEFAULT_ERROR_OUT stderr #endif -static struct { - ERROR_LOG_LEVEL logLevel; - FILE *out; - int style; /* 1=MSVC */ - char disabled[MAX_ERROR_WARNING]; /* 1=warning disabled*/ -} _SDCCERRG; +struct SDCCERRG _SDCCERRG; extern char *filename ; extern int lineno ; diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index a08c8412..dc2614db 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -221,6 +221,15 @@ enum _ERROR_LOG_LEVEL { typedef enum _ERROR_LOG_LEVEL ERROR_LOG_LEVEL; +struct SDCCERRG { + ERROR_LOG_LEVEL logLevel; + FILE *out; + int style; /* 1=MSVC */ + char disabled[MAX_ERROR_WARNING]; /* 1=warning disabled*/ +}; + +extern struct SDCCERRG _SDCCERRG; + /** Sets the maximum error level to log. See MAX_ERROR_LEVEL. The default is ERROR_LEVEL_ALL. */