From 36539e2934fa438075bd088a5eef1886809783c9 Mon Sep 17 00:00:00 2001 From: borutr Date: Mon, 12 Jan 2004 12:56:48 +0000 Subject: [PATCH] upper case pragmas are deprecated git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3118 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 5 ++ doc/sdccman.lyx | 141 +++++++++++++++++++++-------------------- src/SDCC.lex | 85 +++++++++++++++++-------- support/Util/SDCCerr.c | 4 +- support/Util/SDCCerr.h | 1 + 5 files changed, 138 insertions(+), 98 deletions(-) diff --git a/ChangeLog b/ChangeLog index b87b812a..6004c213 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-01-12 Borut Razem + + * src/SDCC.lex, support/Util/SDCCerr.h, support/Util/SDCCerr.c, + doc/sdccman.lyx: upper case pragmas are deprecated + 2004-01-12 Bernhard Held * src/SDCCast.c (decorateType): replacing 'ul > 0' by '!ul' results diff --git a/doc/sdccman.lyx b/doc/sdccman.lyx index 135ae7af..5a5a52fb 100644 --- a/doc/sdccman.lyx +++ b/doc/sdccman.lyx @@ -5997,8 +5997,8 @@ status Collapsed A warning message will be generated when this happens and the compiler will indicate the number of extra bytes it allocated. It is recommended that this option NOT be used, #pragma\SpecialChar ~ -NOGCSE -\begin_inset LatexCommand \index{\#pragma NOGCSE} +nogcse +\begin_inset LatexCommand \index{\#pragma nogcse} \end_inset @@ -6034,8 +6034,8 @@ status Collapsed explained for the previous option. For more details of loop optimizations performed see section Loop Invariants. It is recommended that this option NOT be used, #pragma\SpecialChar ~ -NOINVARIANT -\begin_inset LatexCommand \index{\#pragma NOINVARIANT} +noinvariant +\begin_inset LatexCommand \index{\#pragma noinvariant} \end_inset @@ -6065,8 +6065,8 @@ status Collapsed Will not do loop induction optimizations, see section strength reduction for more details. It is recommended that this option is NOT used, #pragma\SpecialChar ~ -NOINDUCTION -\begin_inset LatexCommand \index{\#pragma NOINDUCTION} +noinduction +\begin_inset LatexCommand \index{\#pragma noinduction} \end_inset @@ -6112,8 +6112,8 @@ status Collapsed \SpecialChar ~ Switch Statements for more details. It is recommended that this option is NOT used, #pragma\SpecialChar ~ -NOJTBOUND -\begin_inset LatexCommand \index{\#pragma NOJTBOUND} +nojtbound +\begin_inset LatexCommand \index{\#pragma nojtbound} \end_inset @@ -6520,8 +6520,8 @@ status Collapsed -callee-saves option string. Also see #pragma\SpecialChar ~ -CALLEE-SAVES -\begin_inset LatexCommand \index{\#pragma CALLEE-SAVES} +callee_saves +\begin_inset LatexCommand \index{\#pragma callee\_saves} \end_inset @@ -9160,8 +9160,8 @@ Note that the compiler (not the linkage editor) makes the decision for overlayin g the data items. Functions that are called from an interrupt service routine should be preceded by a #pragma\SpecialChar ~ -NOOVERLAY -\begin_inset LatexCommand \index{\#pragma NOOVERLAY} +nooverlay +\begin_inset LatexCommand \index{\#pragma nooverlay} \end_inset @@ -9173,7 +9173,7 @@ Also note that the compiler does not do any processing of inline assembler of a function into the overlay segment if the inline assembler code calls other c-functions that might use the overlay. In that case the #pragma\SpecialChar ~ -NOOVERLAY should be used. +nooverlay should be used. \layout Standard Parameters and local variables of functions that contain 16 or 32 bit multiplica @@ -9193,10 +9193,10 @@ tion \family typewriter -#pragma SAVE +#pragma save \newline -#pragma NOOVERLAY -\begin_inset LatexCommand \index{\#pragma NOOVERLAY} +#pragma nooverlay +\begin_inset LatexCommand \index{\#pragma nooverlay} \end_inset @@ -9214,7 +9214,7 @@ P3 = errcd; \newline } \newline -#pragma RESTORE +#pragma restore \newline \newline @@ -9258,11 +9258,11 @@ errcd set_error \emph default would be assigned to the overlayable segment if the #pragma\SpecialChar ~ -NOOVERLAY was +nooverlay was not present, this could cause unpredictable runtime behavior when called from an interrupt service routine. The #pragma\SpecialChar ~ -NOOVERLAY ensures that the parameters and local variables for +nooverlay ensures that the parameters and local variables for the function are NOT overlayed. \layout Section @@ -9735,8 +9735,8 @@ Calling other functions from an interrupt service routine is not recommended, avoid it if possible. Note that when some function is called from an interrupt service routine it should be preceded by a #pragma\SpecialChar ~ -NOOVERLAY -\begin_inset LatexCommand \index{\#pragma NOOVERLAY} +nooverlay +\begin_inset LatexCommand \index{\#pragma nooverlay} \end_inset @@ -11203,8 +11203,8 @@ reti\SpecialChar ~ ; MUST explicitly include ret or reti in _naked function \layout Standard -The related #pragma directive EXCLUDE -\begin_inset LatexCommand \index{\#pragma EXCLUDE} +The related directive #pragma exclude +\begin_inset LatexCommand \index{\#pragma exclude} \end_inset @@ -13202,45 +13202,45 @@ Pragmas SDCC supports the following #pragma directives: \layout Itemize -SAVE -\begin_inset LatexCommand \index{\#pragma SAVE} +save +\begin_inset LatexCommand \index{\#pragma save} \end_inset - - this will save all current options to the SAVE/RESTORE stack. - See RESTORE. + - this will save all current options to the save/restore stack. + See restore. \layout Itemize -RESTORE -\begin_inset LatexCommand \index{\#pragma RESTORE} +restore +\begin_inset LatexCommand \index{\#pragma restore} \end_inset - will restore saved options from the last save. - SAVEs & RESTOREs can be nested. - SDCC uses a SAVE/RESTORE stack: SAVE pushes current options to the stack, - RESTORE pulls current options from the stack. - See SAVE. + saves & restores can be nested. + SDCC uses a save/restore stack: save pushes current options to the stack, + restore pulls current options from the stack. + See save. \layout Itemize -NOGCSE -\begin_inset LatexCommand \index{\#pragma NOGCSE} +nogcse +\begin_inset LatexCommand \index{\#pragma nogcse} \end_inset - will stop global common subexpression elimination. \layout Itemize -NOINDUCTION -\begin_inset LatexCommand \index{\#pragma NOINDUCTION} +noinduction +\begin_inset LatexCommand \index{\#pragma noinduction} \end_inset - will stop loop induction optimizations. \layout Itemize -NOJTBOUND -\begin_inset LatexCommand \index{\#pragma NOJTBOUND} +nojtbound +\begin_inset LatexCommand \index{\#pragma nojtbound} \end_inset @@ -13254,8 +13254,8 @@ NOJTBOUND . \layout Itemize -NOOVERLAY -\begin_inset LatexCommand \index{\#pragma NOOVERLAY} +nooverlay +\begin_inset LatexCommand \index{\#pragma nooverlay} \end_inset @@ -13263,8 +13263,8 @@ NOOVERLAY function. \layout Itemize -LESS_PEDANTIC -\begin_inset LatexCommand \index{\#pragma LESS\_PEDANTIC} +less_pedantic +\begin_inset LatexCommand \index{\#pragma less\_pedantic} \end_inset @@ -13272,20 +13272,20 @@ LESS_PEDANTIC your own now ;-( \layout Itemize -NOLOOPREVERSE -\begin_inset LatexCommand \index{\#pragma NOLOOPREVERSE} +noloopreverse +\begin_inset LatexCommand \index{\#pragma noloopreverse} \end_inset - Will not do loop reversal optimization \layout Itemize -EXCLUDE -\begin_inset LatexCommand \index{\#pragma EXCLUDE} +exclude +\begin_inset LatexCommand \index{\#pragma exclude} \end_inset - NONE | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of + none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables generation of pair of push/pop \begin_inset LatexCommand \index{push/pop} @@ -13300,17 +13300,17 @@ EXCLUDE The directive should be placed immediately before the ISR function definition and it affects ALL ISR functions following it. To enable the normal register saving for ISR functions use #pragma\SpecialChar ~ -EXCLUDE\SpecialChar ~ +exclude\SpecialChar ~ none -\begin_inset LatexCommand \index{\#pragma EXCLUDE} +\begin_inset LatexCommand \index{\#pragma exclude} \end_inset . \layout Itemize -NOIV -\begin_inset LatexCommand \index{\#pragma NOIV} +noiv +\begin_inset LatexCommand \index{\#pragma noiv} \end_inset @@ -13334,8 +13334,8 @@ NOIV about interrupts. \layout Itemize -CALLEE-SAVES -\begin_inset LatexCommand \index{\#pragma CALLEE-SAVES} +callee_saves +\begin_inset LatexCommand \index{\#pragma callee\_saves} \end_inset @@ -13372,12 +13372,15 @@ status Collapsed -callee-saves command line option is used, the function names specified in #pragma\SpecialChar ~ -CALLEE-SAVES -\begin_inset LatexCommand \index{\#pragma CALLEE-SAVES} +callee_saves +\begin_inset LatexCommand \index{\#pragma callee\_saves} \end_inset is appended to the list of functions specified in the command line. +\layout Standard + +SDCPP supports the following #pragma directives: \layout Itemize preproc_asm @@ -13401,8 +13404,8 @@ The pragma's are intended to be used to turn-on or off certain optimizations \family typewriter -#pragma SAVE -\begin_inset LatexCommand \index{\#pragma SAVE} +#pragma save +\begin_inset LatexCommand \index{\#pragma save} \end_inset @@ -13415,8 +13418,8 @@ The pragma's are intended to be used to turn-on or off certain optimizations \SpecialChar ~ /* save the current settings */ \newline -#pragma NOGCSE -\begin_inset LatexCommand \index{\#pragma NOGCSE} +#pragma nogcse +\begin_inset LatexCommand \index{\#pragma nogcse} \end_inset @@ -13427,8 +13430,8 @@ The pragma's are intended to be used to turn-on or off certain optimizations \SpecialChar ~ /* turnoff global subexpression elimination */ \newline -#pragma NOINDUCTION -\begin_inset LatexCommand \index{\#pragma NOINDUCTION} +#pragma noinduction +\begin_inset LatexCommand \index{\#pragma noinduction} \end_inset @@ -13454,8 +13457,8 @@ int foo () \newline } \newline -#pragma RESTORE -\begin_inset LatexCommand \index{\#pragma RESTORE} +#pragma restore +\begin_inset LatexCommand \index{\#pragma restore} \end_inset @@ -13463,7 +13466,7 @@ int foo () \layout Standard The compiler will generate a warning message when extra space is allocated. - It is strongly recommended that the SAVE and RESTORE pragma's be used when + It is strongly recommended that the save and restore pragma's be used when changing options for a function. \layout Section @@ -16993,8 +16996,8 @@ status Collapsed \end_inset -noinduction option) or for a given function only using #pragma\SpecialChar ~ -NOINDUCTION -\begin_inset LatexCommand \index{\#pragma NOINDUCTION} +noinduction +\begin_inset LatexCommand \index{\#pragma noinduction} \end_inset @@ -17589,8 +17592,8 @@ then both the switch statements will be implemented using jump-tables whereas You might also consider inserting dummy cases 0 and 5 to 8 in this example. \newline -The pragma NOJTBOUND -\begin_inset LatexCommand \index{\#pragma NOJTBOUND} +The pragma nojtbound +\begin_inset LatexCommand \index{\#pragma nojtbound} \end_inset diff --git a/src/SDCC.lex b/src/SDCC.lex index 6bfb6e1a..7f64c976 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -569,27 +569,51 @@ static int process_pragma(char *s) #define PRAGMA_STR "#pragma" #define PRAGMA_LEN ((sizeof PRAGMA_STR) - 1) - static struct pragma_s { - const char *name; - enum pragma_id id; - } pragma_tbl[] = { - { "SAVE", P_SAVE }, - { "RESTORE", P_RESTORE }, - { "NOINDUCTION", P_NOINDUCTION }, - { "NOINVARIANT", P_NOINVARIANT }, - { "NOLOOPREVERSE", P_LOOPREV }, - { "INDUCTION", P_INDUCTION }, - { "STACKAUTO", P_STACKAUTO }, - { "NOJTBOUND", P_NOJTBOUND }, - { "NOGCSE", P_NOGCSE }, - { "NOOVERLAY", P_NOOVERLAY }, - { "CALLEE-SAVES", P_CALLEE_SAVES }, - { "EXCLUDE", P_EXCLUDE }, - { "NOIV", P_NOIV }, - { "OVERLAY", P_OVERLAY_ }, - { "LESS_PEDANTIC", P_LESSPEDANTIC }, + static struct pragma_s + { + const char *name; + enum pragma_id id; + char deprecated; + } pragma_tbl[] = { + { "save", P_SAVE, 0 }, + { "restore", P_RESTORE, 0 }, + { "noinduction", P_NOINDUCTION, 0 }, + { "noinvariant", P_NOINVARIANT, 0 }, + { "noloopreverse", P_LOOPREV, 0 }, + { "induction", P_INDUCTION, 0 }, + { "stackauto", P_STACKAUTO, 0 }, + { "nojtbound", P_NOJTBOUND, 0 }, + { "nogcse", P_NOGCSE, 0 }, + { "nooverlay", P_NOOVERLAY, 0 }, + { "callee_saves", P_CALLEE_SAVES, 0 }, + { "exclude", P_EXCLUDE, 0 }, + { "noiv", P_NOIV, 0 }, + { "overlay", P_OVERLAY_, 0 }, + { "less_pedantic", P_LESSPEDANTIC, 0 }, + + /* + * The following lines are deprecated pragmas, + * only for bacward compatibility. + * They should be removed in next major release after 1.4.0 + */ + + { "SAVE", P_SAVE, 1 }, + { "RESTORE", P_RESTORE, 1 }, + { "NOINDUCTION", P_NOINDUCTION, 1 }, + { "NOINVARIANT", P_NOINVARIANT, 1 }, + { "NOLOOPREVERSE", P_LOOPREV, 1 }, + { "INDUCTION", P_INDUCTION, 1 }, + { "STACKAUTO", P_STACKAUTO, 1 }, + { "NOJTBOUND", P_NOJTBOUND, 1 }, + { "NOGCSE", P_NOGCSE, 1 }, + { "NOOVERLAY", P_NOOVERLAY, 1 }, + { "CALLEE-SAVES", P_CALLEE_SAVES, 1 }, + { "EXCLUDE", P_EXCLUDE, 1 }, + { "NOIV", P_NOIV, 1 }, + { "OVERLAY", P_OVERLAY_, 1 }, + { "LESS_PEDANTIC", P_LESSPEDANTIC, 1 }, }; - char *cp ; + char *cp; int i; /* find the pragma */ @@ -610,17 +634,22 @@ static int process_pragma(char *s) if (port->process_pragma && !port->process_pragma(cp)) return 0; - for (i = 0; i < NELEM(pragma_tbl); i++) { - /* now compare and do what needs to be done */ - size_t len = strlen(pragma_tbl[i].name); + for (i = 0; i < NELEM(pragma_tbl); i++) + { + /* now compare and do what needs to be done */ + size_t len = strlen(pragma_tbl[i].name); - if (strncmp(cp, pragma_tbl[i].name, len) == 0) { - doPragma(pragma_tbl[i].id, cp + len); - return 0; + if (strncmp(cp, pragma_tbl[i].name, len) == 0) + { + if (pragma_tbl[i].deprecated != 0) + werror(W_DEPRECATED_PRAGMA, pragma_tbl[i].name); + + doPragma(pragma_tbl[i].id, cp + len); + return 0; + } } - } - werror(W_UNKNOWN_PRAGMA,cp); + werror(W_UNKNOWN_PRAGMA, cp); return 0; } diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index 374c383b..c78c672f 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -396,7 +396,7 @@ struct { E_FUNC_ATTR, ERROR_LEVEL_ERROR, "function attribute following non-function declaration"}, { W_SAVE_RESTORE, ERROR_LEVEL_PEDANTIC, - "unmatched #pragma SAVE and #pragma RESTORE" }, + "unmatched #pragma save and #pragma restore" }, { E_INVALID_CRITICAL, ERROR_LEVEL_ERROR, "not allowed in a critical section" }, { E_NOT_ALLOWED, ERROR_LEVEL_ERROR, @@ -405,6 +405,8 @@ struct "'%s' is not a %s tag" }, { E_ENUM_NON_INTEGER, ERROR_LEVEL_ERROR, "enumeration constant not an integer" }, +{ W_DEPRECATED_PRAGMA, ERROR_LEVEL_WARNING, + "pragma %s is deprecated, please see documentation for details" }, }; /* diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index a81361b2..9f542db2 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -190,6 +190,7 @@ SDCCERR - SDCC Standard error handler #define E_NOT_ALLOWED 172 /* %s not allowed here */ #define E_BAD_TAG 173 /* '%s' is not a %s tag */ #define E_ENUM_NON_INTEGER 174 /* enumeration constant not an integer */ +#define W_DEPRECATED_PRAGMA 175 /* deprecated pragma */ /** Describes the maximum error level that will be logged. Any level * includes all of the levels listed after it. -- 2.30.2