]> git.gag.com Git - fw/sdcc/commitdiff
some small fixes
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Dec 2001 16:57:38 +0000 (16:57 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 24 Dec 2001 16:57:38 +0000 (16:57 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1737 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCast.c
src/SDCCglue.c
src/SDCCmem.c

index c121d7c2081ee3ff6eecb3b3867a77fb7ffd779c..15f59285a84add354e7611937d698e1eadc1f75c 100644 (file)
@@ -1170,6 +1170,12 @@ bool constExprTree (ast *cexpr) {
        // a function's address will never change
        return TRUE;
       }
+      if (IS_AST_SYM_VALUE(cexpr) && 
+         IN_CODESPACE(SPEC_OCLS(AST_SYMBOL(cexpr)->etype))) {
+       // a symbol in code space will never change
+       // This is only for the 'char *s="hallo"' case and will have to leave
+       return TRUE;
+      }
       return FALSE;
     case EX_LINK:
       werror (E_INTERNAL_ERROR, __FILE__, __LINE__,
@@ -1177,6 +1183,7 @@ bool constExprTree (ast *cexpr) {
       return FALSE;
     case EX_OP:
       if (cexpr->opval.op==ARRAYINIT) {
+       fprintf (stderr, "skipping arrayinit\n");
        // this is a list of literals
        return TRUE;
       }
index 6f89cb01db600a67b5fc981255b6ae4edcead1cf..e1e8f3232069203868c5db506bb60b0e94e1d9c8 100644 (file)
@@ -272,14 +272,14 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag)
          if (ival) {
            // set ival's lineno to where the symbol was defined
            setAstLineno (ival, lineno=sym->lineDef);
-           // check if this is a constant expression
-           if (constExprTree(ival)) {
-             allocInfo = 0;
-             eBBlockFromiCode (iCodeFromAst (ival));
-             allocInfo = 1;
-           } else {
+           // check if this is not a constant expression
+           if (!constExprTree(ival)) {
              werror (E_CONST_EXPECTED, "found expression");
+             // but try to do it anyway
            }
+           allocInfo = 0;
+           eBBlockFromiCode (iCodeFromAst (ival));
+           allocInfo = 1;
          }
 #endif
        }         
index a0e137d4998f46178c3f452ce389a5f8117738cf..f369a04fda8efd3580aff192be37d82f3efbe3e3 100644 (file)
@@ -381,16 +381,19 @@ allocGlobal (symbol * sym)
     }
 
   /* if it is fixed, then allocate depending on the  */
-  /* current memory model,same for automatics        */
+  /* current memory model, same for automatics        */
   if (SPEC_SCLS (sym->etype) == S_FIXED ||
-      SPEC_SCLS (sym->etype) == S_AUTO)
-    {
+      SPEC_SCLS (sym->etype) == S_AUTO) {
+    if (port->mem.default_globl_map != xdata) {
       /* set the output class */
       SPEC_OCLS (sym->etype) = port->mem.default_globl_map;
       /* generate the symbol  */
       allocIntoSeg (sym);
       return;
+    } else {
+      SPEC_SCLS (sym->etype) = S_XDATA;
     }
+  }
 
   /* if code change to constant */
   if (SPEC_SCLS (sym->etype) == S_CODE) {