1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-13 09:31:53 +00:00

Changed names of the pragmas to be identical to the corresponding command line

options. This should make use easier. The old names of the pragmas are still
available but will cause warnings.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4364 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2009-10-14 12:55:15 +00:00
parent 869a1369c4
commit ed2767e65f
8 changed files with 179 additions and 106 deletions

View File

@ -3,7 +3,7 @@
<article> <article>
<title>cc65 Users Guide <title>cc65 Users Guide
<author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org"> <author>Ullrich von Bassewitz, <htmlurl url="mailto:uz@cc65.org" name="uz@cc65.org">
<date>03.09.2000, 02.10.2001, 2005-8-1 <date>2000-09-03, 2001-10-02, 2005-08-01
<abstract> <abstract>
cc65 is a C compiler for 6502 targets. It supports several 6502 based home cc65 is a C compiler for 6502 targets. It supports several 6502 based home
@ -23,11 +23,7 @@ John R. Dunning. In prior releases I've described the compiler by listing
up the changes made by me. I have made many more changes in the meantime up the changes made by me. I have made many more changes in the meantime
(and rewritten major parts of the compiler), so I will no longer do that, (and rewritten major parts of the compiler), so I will no longer do that,
since the list would be too large and of no use to anyone. Instead I will since the list would be too large and of no use to anyone. Instead I will
describe the compiler in respect to the ANSI/ISO C standard. In fact, I'm describe the compiler in respect to the ANSI/ISO C standard.
planning a complete rewrite (that is, a complete new compiler) for the
next release, since there are too many limitations in the current code,
and removing these limitations would mean a rewrite of many more parts of
the compiler.
There are separate documents named <url url="library.html"> and <url There are separate documents named <url url="library.html"> and <url
url="funcref.html"> that cover the library that is available for the compiler. url="funcref.html"> that cover the library that is available for the compiler.
@ -108,21 +104,26 @@ Here is a description of all the command line options:
<descrip> <descrip>
<label id="option-bss-name">
<tag><tt>--bss-name seg</tt></tag> <tag><tt>--bss-name seg</tt></tag>
Set the name of the bss segment. Set the name of the bss segment. See also <tt/<ref id="pragma-bss-name"
name="#pragma&nbsp;bss-name">/.
<label id="option-check-stack">
<tag><tt>--check-stack</tt></tag> <tag><tt>--check-stack</tt></tag>
Tells the compiler to generate code that checks for stack overflows. See Tells the compiler to generate code that checks for stack overflows. See
<tt><ref id="pragma-checkstack" name="#pragma&nbsp;checkstack"></tt> for an <tt/<ref id="pragma-check-stack" name="#pragma&nbsp;check-stack">/ for an
explanation of this feature. explanation of this feature.
<label id="option-code-name">
<tag><tt>--code-name seg</tt></tag> <tag><tt>--code-name seg</tt></tag>
Set the name of the code segment. Set the name of the code segment. See also <tt/<ref id="pragma-code-name"
name="#pragma&nbsp;code-name">/
<label id="option-codesize"> <label id="option-codesize">
@ -134,6 +135,7 @@ Here is a description of all the command line options:
using <tt/-Oi/ (<tt/-Oi/ is the same as <tt/-O --codesize&nbsp;200/). using <tt/-Oi/ (<tt/-Oi/ is the same as <tt/-O --codesize&nbsp;200/).
<label id="option-cpu">
<tag><tt>--cpu CPU</tt></tag> <tag><tt>--cpu CPU</tt></tag>
A new, still experimental option. You may specify "6502" or "65C02" as A new, still experimental option. You may specify "6502" or "65C02" as
@ -144,6 +146,7 @@ Here is a description of all the command line options:
overwhelming. overwhelming.
<label id="option-create-dep">
<tag><tt>--create-dep</tt></tag> <tag><tt>--create-dep</tt></tag>
Tells the compiler to generate a file containing the dependency list for Tells the compiler to generate a file containing the dependency list for
@ -151,6 +154,13 @@ Here is a description of all the command line options:
file with the extension replaced by <tt/.u/. file with the extension replaced by <tt/.u/.
<label id="option-data-name">
<tag><tt>--data-name seg</tt></tag>
Set the name of the data segment. See also <tt/<ref id="pragma-data-name"
name="#pragma&nbsp;data-name">/
<tag><tt>-d, --debug</tt></tag> <tag><tt>-d, --debug</tt></tag>
Enables debug mode, something that should not be needed for mere Enables debug mode, something that should not be needed for mere
@ -188,6 +198,7 @@ Here is a description of all the command line options:
name of the C input file is used, with the extension replaced by ".s". name of the C input file is used, with the extension replaced by ".s".
<label id="option-register-vars">
<tag><tt>-r, --register-vars</tt></tag> <tag><tt>-r, --register-vars</tt></tag>
<tt/-r/ will make the compiler honor the <tt/register/ keyword. Local <tt/-r/ will make the compiler honor the <tt/register/ keyword. Local
@ -197,13 +208,14 @@ Here is a description of all the command line options:
variables are of limited use without the optimizer, there is also a combined variables are of limited use without the optimizer, there is also a combined
switch: <tt/-Or/ will enable both, the optimizer and register variables. switch: <tt/-Or/ will enable both, the optimizer and register variables.
For more information about register variables see <ref id="regvars" For more information about register variables see <ref id="register-vars"
name="register variables">. name="register variables">.
The compiler setting can also be changed within the source file by using The compiler setting can also be changed within the source file by using
<tt><ref id="pragma-regvars" name="#pragma&nbsp;regvars"></tt>. <tt/<ref id="pragma-register-vars" name="#pragma&nbsp;register-vars">/.
<label id="option-register-space">
<tag><tt>--register-space</tt></tag> <tag><tt>--register-space</tt></tag>
This option takes a numeric parameter and is used to specify, how much This option takes a numeric parameter and is used to specify, how much
@ -217,19 +229,21 @@ Here is a description of all the command line options:
If you don't know what all this means, please don't use this option. If you don't know what all this means, please don't use this option.
<label id="option-rodata-name">
<tag><tt>--rodata-name seg</tt></tag> <tag><tt>--rodata-name seg</tt></tag>
Set the name of the rodata segment (the segment used for readonly data). Set the name of the rodata segment (the segment used for readonly data).
See also <tt/<ref id="pragma-rodata-name" name="#pragma&nbsp;rodata-name">/
<label id="option-signed-chars">
<tag><tt>-j, --signed-chars</tt></tag> <tag><tt>-j, --signed-chars</tt></tag>
Using this option, you can make the default characters signed. Since the Using this option, you can make the default characters signed. Since the
6502 has no provisions for sign extending characters (which is needed on 6502 has no provisions for sign extending characters (which is needed on
almost any load operation), this will make the code larger and slower. A almost any load operation), this will make the code larger and slower. A
better way is to declare characters explicitly as "signed" if needed. You better way is to declare characters explicitly as "signed" if needed. You
can also use <tt><ref id="pragma-signedchars" can also use <tt><ref id="pragma-signed-chars"
name="#pragma&nbsp;signedchars"></tt> for better control of this option. name="#pragma&nbsp;signed-chars"></tt> for better control of this option.
<label id="option--standard"> <label id="option--standard">
@ -248,6 +262,7 @@ Here is a description of all the command line options:
(// comments for example). (// comments for example).
<label id="option-standard">
<tag><tt>-t target, --target target</tt></tag> <tag><tt>-t target, --target target</tt></tag>
This option is used to set the target system. The target system This option is used to set the target system. The target system
@ -281,12 +296,14 @@ Here is a description of all the command line options:
or warnings are encountered. or warnings are encountered.
<label id="option-writable-strings">
<tag><tt>--writable-strings</tt></tag> <tag><tt>--writable-strings</tt></tag>
Make string literals writable by placing them into the data segment instead Make string literals writable by placing them into the data segment instead
of the rodata segment. of the rodata segment.
<label id="option-static-locals">
<tag><tt>-Cl, --static-locals</tt></tag> <tag><tt>-Cl, --static-locals</tt></tag>
Use static storage for local variables instead of storage on the stack. Use static storage for local variables instead of storage on the stack.
@ -319,11 +336,12 @@ Here is a description of all the command line options:
function is entered, and will keep the old value from one call of the function is entered, and will keep the old value from one call of the
function to the next. function to the next.
You may also use <tt><ref id="pragma-staticlocals" You may also use <tt><ref id="pragma-static-locals"
name="#pragma&nbsp;staticlocals"></tt> to change this setting in your name="#pragma&nbsp;static-locals"></tt> to change this setting in your
sources. sources.
<label id="option-include-dir">
<tag><tt>-I dir, --include-dir dir</tt></tag> <tag><tt>-I dir, --include-dir dir</tt></tag>
Set a directory where the compiler searches for include files. You may Set a directory where the compiler searches for include files. You may
@ -344,10 +362,9 @@ Here is a description of all the command line options:
<tt/-Or/ will make the compiler honor the <tt/register/ keyword. Local <tt/-Or/ will make the compiler honor the <tt/register/ keyword. Local
variables may be placed in registers (which are actually zero page variables may be placed in registers (which are actually zero page
locations). There is some overhead involved with register variables, since locations). See also the <tt/<ref id="option-register-vars"
the old contents of the registers must be saved and restored. In addition, name="--register-vars">/ command line option, and the <ref
the current implementation does not make good use of register variables, so id="register-vars" name="discussion of register variables"> below.
using <tt/-Or/ may make your program even slower and larger. Use with care!
Using <tt/-Os/ will force the compiler to inline some known functions from Using <tt/-Os/ will force the compiler to inline some known functions from
the C library like strlen. Note: This has two consequences: the C library like strlen. Note: This has two consequences:
@ -405,6 +422,9 @@ Here is a description of all the command line options:
Warn about unused variables. Warn about unused variables.
</descrip> </descrip>
You may also use <tt><ref id="pragma-warn" name="#pragma&nbsp;warn"></tt> to
control this setting for smaller pieces of code from within your code.
</descrip><p> </descrip><p>
@ -731,7 +751,7 @@ If the first parameter is <tt/push/, the old value is saved onto a stack
before changing it. The value may later be restored by using the <tt/pop/ before changing it. The value may later be restored by using the <tt/pop/
parameter with the <tt/#pragma/. parameter with the <tt/#pragma/.
<sect1><tt>#pragma bssseg (&lsqb;push,&rsqb; &lt;name&gt;)</tt><p> <sect1><tt>#pragma bss-name (&lsqb;push,&rsqb; &lt;name&gt;)</tt><label id="pragma-bss-name"><p>
This pragma changes the name used for the BSS segment (the BSS segment This pragma changes the name used for the BSS segment (the BSS segment
is used to store uninitialized data). The argument is a string enclosed is used to store uninitialized data). The argument is a string enclosed
@ -749,11 +769,11 @@ parameter with the <tt/#pragma/.
Example: Example:
<tscreen><verb> <tscreen><verb>
#pragma bssseg ("MyBSS") #pragma bss-name ("MyBSS")
</verb></tscreen> </verb></tscreen>
<sect1><tt>#pragma charmap (&lt;index&gt;, &lt;code&gt;)</tt><p> <sect1><tt>#pragma charmap (&lt;index&gt;, &lt;code&gt;)</tt><label id="pragma-charmap"><p>
Each literal string and each literal character in the source is translated Each literal string and each literal character in the source is translated
by use of a translation table. This translation table is preset when the by use of a translation table. This translation table is preset when the
@ -787,7 +807,7 @@ parameter with the <tt/#pragma/.
</verb></tscreen> </verb></tscreen>
<sect1><tt>#pragma checkstack ([push,] on|off)</tt><label id="pragma-checkstack"><p> <sect1><tt>#pragma check-stack ([push,] on|off)</tt><label id="pragma-check-stack"><p>
Tells the compiler to insert calls to a stack checking subroutine to detect Tells the compiler to insert calls to a stack checking subroutine to detect
stack overflows. The stack checking code will lead to somewhat larger and stack overflows. The stack checking code will lead to somewhat larger and
@ -800,7 +820,7 @@ parameter with the <tt/#pragma/.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma codeseg ([push,] &lt;name&gt;)</tt><p> <sect1><tt>#pragma code-name ([push,] &lt;name&gt;)</tt><label id="pragma-code-name"><p>
This pragma changes the name used for the CODE segment (the CODE segment This pragma changes the name used for the CODE segment (the CODE segment
is used to store executable code). The argument is a string enclosed in is used to store executable code). The argument is a string enclosed in
@ -814,7 +834,7 @@ parameter with the <tt/#pragma/.
Example: Example:
<tscreen><verb> <tscreen><verb>
#pragma codeseg ("MyCODE") #pragma code-name ("MyCODE")
</verb></tscreen> </verb></tscreen>
@ -828,7 +848,7 @@ parameter with the <tt/#pragma/.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma dataseg ([push,] &lt;name&gt;)</tt><p> <sect1><tt>#pragma data-name ([push,] &lt;name&gt;)</tt><label id="pragma-data-name"><p>
This pragma changes the name used for the DATA segment (the DATA segment This pragma changes the name used for the DATA segment (the DATA segment
is used to store initialized data). The argument is a string enclosed in is used to store initialized data). The argument is a string enclosed in
@ -842,7 +862,7 @@ parameter with the <tt/#pragma/.
Example: Example:
<tscreen><verb> <tscreen><verb>
#pragma dataseg ("MyDATA") #pragma data-name ("MyDATA")
</verb></tscreen> </verb></tscreen>
@ -862,7 +882,7 @@ parameter with the <tt/#pragma/.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma rodataseg ([push,] &lt;name&gt;)</tt><p> <sect1><tt>#pragma rodata-name ([push,] &lt;name&gt;)</tt><label id="pragma-rodata-name"><p>
This pragma changes the name used for the RODATA segment (the RODATA This pragma changes the name used for the RODATA segment (the RODATA
segment is used to store readonly data). The argument is a string segment is used to store readonly data). The argument is a string
@ -876,11 +896,11 @@ parameter with the <tt/#pragma/.
Example: Example:
<tscreen><verb> <tscreen><verb>
#pragma rodataseg ("MyRODATA") #pragma rodata-name ("MyRODATA")
</verb></tscreen> </verb></tscreen>
<sect1><tt>#pragma regvaraddr ([push,] on|off)</tt><p> <sect1><tt>#pragma regvaraddr ([push,] on|off)</tt><label id="pragma-regvaraddr"><p>
The compiler does not allow to take the address of register variables. The compiler does not allow to take the address of register variables.
The regvaraddr pragma changes this. Taking the address of a register The regvaraddr pragma changes this. Taking the address of a register
@ -904,33 +924,34 @@ parameter with the <tt/#pragma/.
</verb></tscreen> </verb></tscreen>
<sect1><tt>#pragma regvars ([push,] on|off)</tt><label id="pragma-regvars"><p> <sect1><tt>#pragma register-vars ([push,] on|off)</tt><label id="pragma-register-vars"><p>
Enables or disables use of register variables. If register variables are Enables or disables use of register variables. If register variables are
disabled (the default), the <tt/register/ keyword is ignored. Register disabled (the default), the <tt/register/ keyword is ignored. Register
variables are explained in more detail in <ref id="regvars" name="a separate variables are explained in more detail in <ref id="register-vars" name="a separate
chapter">. chapter">.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma signedchars ([push,] on|off)</tt><label id="pragma-signedchars"><p> <sect1><tt>#pragma signed-chars ([push,] on|off)</tt><label id="pragma-signed-chars"><p>
Changes the signedness of the default character type. If the argument is Changes the signedness of the default character type. If the argument is
"on", default characters are signed, otherwise characters are unsigned. "on", default characters are signed, otherwise characters are unsigned. The
The compiler default is to make characters unsigned since this creates a compiler default is to make characters unsigned since this creates a lot
lot better code. This default may be overridden by the <tt/--signed-chars/ better code. This default may be overridden by the <tt/<ref
command line option. name="--signed-chars" id="option-signed-chars">/ command line option.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
<sect1><tt>#pragma staticlocals ([push,] on|off)</tt><label id="pragma-staticlocals"<p> <sect1><tt>#pragma static-locals ([push,] on|off)</tt><label id="pragma-static-locals"<p>
Use variables in the bss segment instead of variables on the stack. This Use variables in the bss segment instead of variables on the stack. This
pragma changes the default set by the compiler option <tt/-Cl/. If the pragma changes the default set by the compiler option <tt/<ref
argument is "on", local variables are allocated in the BSS segment, name="--static-locals" id="option-static-locals">/. If the argument is "on",
leading to shorter and in most cases faster, but non-reentrant code. local variables are allocated in the BSS segment, leading to shorter and in
most cases faster, but non-reentrant code.
The <tt/#pragma/ understands the push and pop parameters as explained above. The <tt/#pragma/ understands the push and pop parameters as explained above.
@ -943,6 +964,16 @@ parameter with the <tt/#pragma/.
"off", optionally preceeded by "push" to push the current state before "off", optionally preceeded by "push" to push the current state before
changing it. changing it.
Example:
<tscreen><verb>
/* Don't warn about the unused parameter in function func */
#pragma warn (unused-param, push, off)
static int func (int unused)
{
return 0;
}
#pragma warn (unused-param, pop)
</verb></tscreen>
<sect1><tt>#pragma zpsym (&lt;name&gt;)</tt><p> <sect1><tt>#pragma zpsym (&lt;name&gt;)</tt><p>
@ -959,7 +990,7 @@ parameter with the <tt/#pragma/.
<sect>Register variables<label id="regvars"><p> <sect>Register variables<label id="register-vars"><p>
The runtime for all supported platforms has 6 bytes of zero page space The runtime for all supported platforms has 6 bytes of zero page space
available for register variables (this could be increased, but I think it's a available for register variables (this could be increased, but I think it's a
@ -989,11 +1020,13 @@ much difference in the code generated for counters, so you will need at least
trouble. The only savings you get here are by the use of a zero page variable trouble. The only savings you get here are by the use of a zero page variable
instead of one on the stack or in the data segment. instead of one on the stack or in the data segment.
Register variables must be explicitly enabled by using <tt/-Or/ or <tt/-r/ on Register variables must be explicitly enabled, either by using <tt/<ref
the command line. Register variables are only accepted on function top level, name="-Or" id="option-O">/ or <tt/<ref name="--register-vars"
register variables declared in interior blocks are silently converted to id="option-register-vars">/ on the command line or by use of <tt/<ref
<tt/auto/. With register variables disabled, all variables declared as name="#pragma register-vars" id="pragma-register-vars">/. Register variables
<tt/register/ are actually auto variables. are only accepted on function top level, register variables declared in
interior blocks are silently converted to <tt/auto/. With register variables
disabled, all variables declared as <tt/register/ are actually auto variables.
Please take care when using register variables: While they are helpful and can Please take care when using register variables: While they are helpful and can
lead to a tremendous speedup when used correctly, improper usage will cause lead to a tremendous speedup when used correctly, improper usage will cause

View File

@ -31,7 +31,7 @@
extern void __fastcall__ _seterrno (unsigned char code); extern void __fastcall__ _seterrno (unsigned char code);
#pragma staticlocals(on) #pragma static-locals(on)

View File

@ -40,7 +40,7 @@
/* Use static local variables for speed */ /* Use static local variables for speed */
#pragma staticlocals (on); #pragma static-locals (on);
@ -135,7 +135,7 @@ size_t __fastcall__ strftime (char* buf, size_t bufsize, const char* format,
break; break;
case 'W': case 'W':
sprintf (arg, "%02d", sprintf (arg, "%02d",
(tm->tm_yday + 7 - (tm->tm_wday? tm->tm_wday - 1 : 6)) / 7); (tm->tm_yday + 7 - (tm->tm_wday? tm->tm_wday - 1 : 6)) / 7);
break; break;

View File

@ -55,7 +55,7 @@
/* Use static local variables for speed */ /* Use static local variables for speed */
#pragma staticlocals (1); #pragma static-locals (1);

View File

@ -34,7 +34,7 @@
#endif #endif
/* Use static local variables for speed */ /* Use static local variables for speed */
#pragma staticlocals (1); #pragma static-locals (1);
@ -90,7 +90,7 @@ int main (void)
clrscr (); clrscr ();
/* Load the graphics driver */ /* Load the graphics driver */
cprintf ("initializing... mompls\r\n"); cprintf ("initializing... mompls\r\n");
tgi_load_driver (tgi_stddrv); tgi_load_driver (tgi_stddrv);
err = tgi_geterror (); err = tgi_geterror ();

View File

@ -50,7 +50,7 @@
/* Use static local variables for speed */ /* Use static local variables for speed */
#pragma staticlocals (1); #pragma static-locals (1);

View File

@ -38,7 +38,7 @@ static unsigned char Sieve[COUNT];
#pragma staticlocals(1); #pragma static-locals(1);

View File

@ -62,43 +62,59 @@
/* Tokens for the #pragmas */ /* Tokens for the #pragmas */
typedef enum { typedef enum {
PR_ILLEGAL = -1, PRAGMA_ILLEGAL = -1,
PR_BSSSEG, PRAGMA_BSS_NAME,
PR_CHARMAP, PRAGMA_BSSSEG, /* obsolete */
PR_CHECKSTACK, PRAGMA_CHARMAP,
PR_CODESEG, PRAGMA_CHECK_STACK,
PR_CODESIZE, PRAGMA_CHECKSTACK, /* obsolete */
PR_DATASEG, PRAGMA_CODE_NAME,
PR_OPTIMIZE, PRAGMA_CODESEG, /* obsolete */
PR_REGVARADDR, PRAGMA_CODESIZE,
PR_REGVARS, PRAGMA_DATA_NAME,
PR_RODATASEG, PRAGMA_DATASEG, /* obsolete */
PR_SIGNEDCHARS, PRAGMA_OPTIMIZE,
PR_STATICLOCALS, PRAGMA_REGVARADDR,
PR_WARN, PRAGMA_REGISTER_VARS,
PR_ZPSYM, PRAGMA_REGVARS, /* obsolete */
PR_COUNT PRAGMA_RODATA_NAME,
PRAGMA_RODATASEG, /* obsolete */
PRAGMA_SIGNED_CHARS,
PRAGMA_SIGNEDCHARS, /* obsolete */
PRAGMA_STATIC_LOCALS,
PRAGMA_STATICLOCALS, /* obsolete */
PRAGMA_WARN,
PRAGMA_ZPSYM,
PRAGMA_COUNT
} pragma_t; } pragma_t;
/* Pragma table */ /* Pragma table */
static const struct Pragma { static const struct Pragma {
const char* Key; /* Keyword */ const char* Key; /* Keyword */
pragma_t Tok; /* Token */ pragma_t Tok; /* Token */
} Pragmas[PR_COUNT] = { } Pragmas[PRAGMA_COUNT] = {
{ "bssseg", PR_BSSSEG }, { "bss-name", PRAGMA_BSS_NAME },
{ "charmap", PR_CHARMAP }, { "bssseg", PRAGMA_BSSSEG }, /* obsolete */
{ "checkstack", PR_CHECKSTACK }, { "charmap", PRAGMA_CHARMAP },
{ "codeseg", PR_CODESEG }, { "check-stack", PRAGMA_CHECK_STACK },
{ "codesize", PR_CODESIZE }, { "checkstack", PRAGMA_CHECKSTACK }, /* obsolete */
{ "dataseg", PR_DATASEG }, { "code-name", PRAGMA_CODE_NAME },
{ "optimize", PR_OPTIMIZE }, { "codeseg", PRAGMA_CODESEG }, /* obsolete */
{ "regvaraddr", PR_REGVARADDR }, { "codesize", PRAGMA_CODESIZE },
{ "regvars", PR_REGVARS }, { "data-name", PRAGMA_DATA_NAME },
{ "rodataseg", PR_RODATASEG }, { "dataseg", PRAGMA_DATASEG }, /* obsolete */
{ "signedchars", PR_SIGNEDCHARS }, { "optimize", PRAGMA_OPTIMIZE },
{ "staticlocals", PR_STATICLOCALS }, { "register-vars", PRAGMA_REGISTER_VARS },
{ "warn", PR_WARN }, { "regvaraddr", PRAGMA_REGVARADDR },
{ "zpsym", PR_ZPSYM }, { "regvars", PRAGMA_REGVARS }, /* obsolete */
{ "rodata-name", PRAGMA_RODATA_NAME },
{ "rodataseg", PRAGMA_RODATASEG }, /* obsolete */
{ "signed-chars", PRAGMA_SIGNED_CHARS },
{ "signedchars", PRAGMA_SIGNEDCHARS }, /* obsolete */
{ "static-locals", PRAGMA_STATIC_LOCALS },
{ "staticlocals", PRAGMA_STATICLOCALS }, /* obsolete */
{ "warn", PRAGMA_WARN },
{ "zpsym", PRAGMA_ZPSYM },
}; };
/* Result of ParsePushPop */ /* Result of ParsePushPop */
@ -137,13 +153,13 @@ static int CmpKey (const void* Key, const void* Elem)
static pragma_t FindPragma (const StrBuf* Key) static pragma_t FindPragma (const StrBuf* Key)
/* Find a pragma and return the token. Return PR_ILLEGAL if the keyword is /* Find a pragma and return the token. Return PRAGMA_ILLEGAL if the keyword is
* not a valid pragma. * not a valid pragma.
*/ */
{ {
struct Pragma* P; struct Pragma* P;
P = bsearch (SB_GetConstBuf (Key), Pragmas, PR_COUNT, sizeof (Pragmas[0]), CmpKey); P = bsearch (SB_GetConstBuf (Key), Pragmas, PRAGMA_COUNT, sizeof (Pragmas[0]), CmpKey);
return P? P->Tok : PR_ILLEGAL; return P? P->Tok : PRAGMA_ILLEGAL;
} }
@ -158,7 +174,7 @@ static int GetComma (StrBuf* B)
Error ("Comma expected"); Error ("Comma expected");
return 0; return 0;
} }
SB_SkipWhite (B); SB_SkipWhite (B);
return 1; return 1;
} }
@ -657,7 +673,7 @@ static void ParsePragma (void)
Pragma = FindPragma (&Ident); Pragma = FindPragma (&Ident);
/* Do we know this pragma? */ /* Do we know this pragma? */
if (Pragma == PR_ILLEGAL) { if (Pragma == PRAGMA_ILLEGAL) {
/* According to the ANSI standard, we're not allowed to generate errors /* According to the ANSI standard, we're not allowed to generate errors
* for unknown pragmas, however, we're allowed to warn - and we will * for unknown pragmas, however, we're allowed to warn - and we will
* do so. Otherwise one typo may give you hours of bug hunting... * do so. Otherwise one typo may give you hours of bug hunting...
@ -679,59 +695,83 @@ static void ParsePragma (void)
/* Switch for the different pragmas */ /* Switch for the different pragmas */
switch (Pragma) { switch (Pragma) {
case PR_BSSSEG: case PRAGMA_BSSSEG:
Warning ("#pragma bssseg is obsolete, please use #pragma bss-name instead");
/* FALLTHROUGH */
case PRAGMA_BSS_NAME:
SegNamePragma (&B, SEG_BSS); SegNamePragma (&B, SEG_BSS);
break; break;
case PR_CHARMAP: case PRAGMA_CHARMAP:
CharMapPragma (&B); CharMapPragma (&B);
break; break;
case PR_CHECKSTACK: case PRAGMA_CHECKSTACK:
Warning ("#pragma checkstack is obsolete, please use #pragma check-stack instead");
/* FALLTHROUGH */
case PRAGMA_CHECK_STACK:
FlagPragma (&B, &CheckStack); FlagPragma (&B, &CheckStack);
break; break;
case PR_CODESEG: case PRAGMA_CODESEG:
Warning ("#pragma codeseg is obsolete, please use #pragma code-name instead");
/* FALLTHROUGH */
case PRAGMA_CODE_NAME:
SegNamePragma (&B, SEG_CODE); SegNamePragma (&B, SEG_CODE);
break; break;
case PR_CODESIZE: case PRAGMA_CODESIZE:
IntPragma (&B, &CodeSizeFactor, 10, 1000); IntPragma (&B, &CodeSizeFactor, 10, 1000);
break; break;
case PR_DATASEG: case PRAGMA_DATASEG:
Warning ("#pragma dataseg is obsolete, please use #pragma data-name instead");
/* FALLTHROUGH */
case PRAGMA_DATA_NAME:
SegNamePragma (&B, SEG_DATA); SegNamePragma (&B, SEG_DATA);
break; break;
case PR_OPTIMIZE: case PRAGMA_OPTIMIZE:
FlagPragma (&B, &Optimize); FlagPragma (&B, &Optimize);
break; break;
case PR_REGVARADDR: case PRAGMA_REGVARADDR:
FlagPragma (&B, &AllowRegVarAddr); FlagPragma (&B, &AllowRegVarAddr);
break; break;
case PR_REGVARS: case PRAGMA_REGVARS:
Warning ("#pragma regvars is obsolete, please use #pragma register-vars instead");
/* FALLTHROUGH */
case PRAGMA_REGISTER_VARS:
FlagPragma (&B, &EnableRegVars); FlagPragma (&B, &EnableRegVars);
break; break;
case PR_RODATASEG: case PRAGMA_RODATASEG:
Warning ("#pragma rodataseg is obsolete, please use #pragma rodata-name instead");
/* FALLTHROUGH */
case PRAGMA_RODATA_NAME:
SegNamePragma (&B, SEG_RODATA); SegNamePragma (&B, SEG_RODATA);
break; break;
case PR_SIGNEDCHARS: case PRAGMA_SIGNEDCHARS:
Warning ("#pragma signedchars is obsolete, please use #pragma signed-chars instead");
/* FALLTHROUGH */
case PRAGMA_SIGNED_CHARS:
FlagPragma (&B, &SignedChars); FlagPragma (&B, &SignedChars);
break; break;
case PR_STATICLOCALS: case PRAGMA_STATICLOCALS:
Warning ("#pragma staticlocals is obsolete, please use #pragma static-locals instead");
/* FALLTHROUGH */
case PRAGMA_STATIC_LOCALS:
FlagPragma (&B, &StaticLocals); FlagPragma (&B, &StaticLocals);
break; break;
case PR_WARN: case PRAGMA_WARN:
WarnPragma (&B); WarnPragma (&B);
break; break;
case PR_ZPSYM: case PRAGMA_ZPSYM:
StringPragma (&B, MakeZPSym); StringPragma (&B, MakeZPSym);
break; break;