]> git.gag.com Git - fw/sdcc/commitdiff
next step towards 16bits short
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Jun 2001 10:40:25 +0000 (10:40 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 13 Jun 2001 10:40:25 +0000 (10:40 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@886 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.y
src/SDCCglobl.h
src/SDCCmain.c
src/SDCCsymt.c

index 7fe71788c8bb5d71c8d135bb40027c4fdace5b91..ff6fd1b0c60e9f4f6d2f31919456d221298ef380 100644 (file)
@@ -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  {
index c7cdc5f937f1efdfb78e1352a7440f4b22747490..ee06a3d23894b3459b4d0af0791b2d539e6ddd72 100644 (file)
@@ -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 */
index 007652abc8c9cec94262bed03447511fd3ce160d..573913a68e775929ffb44f859c2bdd98ef28be40 100644 (file)
@@ -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) 
               {
index 661e8e6a0cedf9af1d99ccc70a9a4dd65d28ddea..bebf6f7449e05934c7b41a5f0b02945583b433a2 100644 (file)
@@ -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);