From: johanknol Date: Wed, 13 Jun 2001 10:40:25 +0000 (+0000) Subject: next step towards 16bits short X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=91de9714407a8df390127a3bdb92fec4668184d5;p=fw%2Fsdcc next step towards 16bits short git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@886 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCC.y b/src/SDCC.y index 7fe71788..ff6fd1b0 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -565,7 +565,7 @@ type_specifier2 | SHORT { $$=newLink(); $$->class = SPECIFIER ; - $$->select.s._short = 1 ; + $$->select.s._short = 1 ; } | INT { $$=newLink(); @@ -580,7 +580,7 @@ type_specifier2 | SIGNED { $$=newLink(); $$->class = SPECIFIER ; - $$->select.s._signed = 1 ; + $$->select.s._signed = 1; } | UNSIGNED { $$=newLink(); @@ -595,7 +595,6 @@ type_specifier2 | CONST { $$=newLink(); $$->class = SPECIFIER ; - //SPEC_SCLS($$) = S_CONSTANT ; SPEC_CONST($$) = 1; } | VOLATILE { diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index c7cdc5f9..ee06a3d2 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -217,6 +217,7 @@ struct options int nostdlib:1; /* Don't use standard lib files */ int nostdinc:1; /* Don't use standard include files */ int verbose:1; /* Show what the compiler is doing */ + int shortisint:1; /* treat short like int or char */ char *calleeSaves[128]; /* list of functions using callee save */ char *excludeRegs[32]; /* registers excluded from saving */ diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 007652ab..573913a6 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -135,6 +135,8 @@ char DefaultExePath[128]; #define OPTION_NOSTDINC "-nostdinc" #define OPTION_VERBOSE "-verbose" #define OPTION_LESS_PEDANTIC "-lesspedantic" +#define OPTION_SHORT_IS_CHAR "-short-is-char" +#define OPTION_SHORT_IS_INT "-short-is-int" static const char *_preCmd[] = { @@ -335,6 +337,7 @@ setDefaultOptions () options.nostdlib = 0; options.nostdinc = 0; options.verbose = 0; + options.shortisint = 0; options.stack10bit=0; @@ -877,6 +880,16 @@ parseCmdLine (int argc, char **argv) options.verbose = 1; continue; } + + if (strcmp (&argv[i][1], OPTION_SHORT_IS_INT) == 0) { + options.shortisint=1; + continue; + } + + if (strcmp (&argv[i][1], OPTION_SHORT_IS_CHAR) == 0) { + options.shortisint=0; + continue; + } if (strcmp (argv[i] +1, OPTION_LESS_PEDANTIC) == 0) { diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 661e8e6a..bebf6f74 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -497,18 +497,14 @@ void checkTypeSanity(sym_link *etype, char *name) { werror (E_SIGNED_OR_UNSIGNED_INVALID, noun, name); } - if (!SPEC_NOUN(etype)) { - // special case for just "signed" or "unsigned" or "long" - if (etype->select.s._signed || SPEC_USIGN(etype) || SPEC_LONG(etype)) { - SPEC_NOUN(etype)=V_INT; - } - // special case for just "short" - if (etype->select.s._short) { - SPEC_NOUN(etype)=V_CHAR; // or maybe V_INT - } + // special case for "short" + if (etype->select.s._short) { + SPEC_NOUN(etype) = options.shortisint ? V_INT : V_CHAR; } - // if still no noun (e.g. "const a;" or "data b;") assume an int + /* if no noun e.g. + "const a;" or "data b;" or "signed s" or "long l" + assume an int */ if (!SPEC_NOUN(etype)) { SPEC_NOUN(etype)=V_INT; } @@ -563,15 +559,15 @@ mergeSpec (sym_link * dest, sym_link * src) if (SPEC_what(dest)) { werror(W_DUPLICATE_SPEC, "what"); } - SPEC_what(dst)=SPEC_what(src); + SPEC_what(dst)|=SPEC_what(src); } #endif // but there are more important thing right now SPEC_LONG (dest) |= SPEC_LONG (src); - dest->select.s._short=src->select.s._short; + dest->select.s._short|=src->select.s._short; SPEC_USIGN (dest) |= SPEC_USIGN (src); - dest->select.s._signed=src->select.s._signed; + dest->select.s._signed|=src->select.s._signed; SPEC_STAT (dest) |= SPEC_STAT (src); SPEC_EXTR (dest) |= SPEC_EXTR (src); SPEC_ABSA (dest) |= SPEC_ABSA (src);