Cleaned up some more mess. Everything should be the same now as on the 12th
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 Mar 2003 15:44:27 +0000 (15:44 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 Mar 2003 15:44:27 +0000 (15:44 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2397 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCC.y
src/SDCCast.c
src/SDCCcse.c
src/SDCCglue.c
src/SDCCicode.c
src/SDCCsymt.c

index c558c6c7390b131bdc5824dc1588c2f5e9ae4598..25ba60f94c3fe74bba1db7dc218c038862df1225 100644 (file)
@@ -603,9 +603,6 @@ type_specifier2
    | CODE      {
                   $$ = newLink (SPECIFIER) ;
                   SPEC_SCLS($$) = S_CODE ;                 
-                 if (port->mem.code_ro) {
-                   SPEC_CONST($$) = 1;
-                 }
                }
    | EEPROM      {
                   $$ = newLink (SPECIFIER) ;
index 0024cff3f35408cb2de43418cc6be5cf6a4f5a81..a2066a19fdd4a6cc70197b1f7f4cb142e207820a 100644 (file)
@@ -2144,7 +2144,7 @@ decorateType (ast * tree)
       {
        sym_link *ltc = (tree->right ? RTYPE (tree) : LTYPE (tree));
        COPYTYPE (TTYPE (tree), TETYPE (tree), ltc);
-       if (!tree->initMode && IS_CONSTANT (TTYPE (tree)))
+       if (!tree->initMode && IS_CONSTANT(TETYPE(tree)))
          werror (E_CODE_WRITE, tree->opval.op==INC_OP ? "++" : "--");
 
        if (tree->right)
@@ -3124,7 +3124,7 @@ decorateType (ast * tree)
       RRVAL (tree) = 1;
       TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "&= or |= or ^= or >>= or <<=");
 
       if (LRVAL (tree))
@@ -3159,7 +3159,7 @@ decorateType (ast * tree)
                               computeType (LTYPE (tree),
                                            RTYPE (tree)));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "-=");
 
       if (LRVAL (tree))
@@ -3200,7 +3200,7 @@ decorateType (ast * tree)
                               computeType (LTYPE (tree),
                                            RTYPE (tree)));
 
-      if (!tree->initMode && IS_CONSTANT (LTYPE (tree)))
+      if (!tree->initMode && IS_CONSTANT (LETYPE (tree)))
        werror (E_CODE_WRITE, "+=");
 
       if (LRVAL (tree))
@@ -3248,7 +3248,7 @@ decorateType (ast * tree)
       RRVAL (tree) = 1;
       LLVAL (tree) = 1;
       if (!tree->initMode ) {
-       if (IS_CONSTANT (LTYPE (tree)))
+       if ((IS_SPEC(LETYPE(tree)) && IS_CONSTANT (LETYPE (tree))))
          werror (E_CODE_WRITE, "=");
       }
       if (LRVAL (tree))
index cde6f7fdffd8e89b52c2412f09ceaa9c7419a155..bc784a21a45aad48e0508589a156d4f8fb7507c4 100644 (file)
@@ -424,6 +424,7 @@ DEFSETFUNC (findPrevIc)
   if (isiCodeEqual (ic, cdp->diCode) &&
       isOperandEqual (cdp->sym, IC_RESULT (cdp->diCode)))
     {
+      *icp = cdp->diCode;
       return 1;
     }
 
@@ -434,6 +435,7 @@ DEFSETFUNC (findPrevIc)
       isOperandEqual (IC_LEFT (ic), IC_RIGHT (cdp->diCode)) &&
       isOperandEqual (IC_RIGHT (ic), IC_LEFT (cdp->diCode)))
     {
+      *icp = cdp->diCode;
       return 1;
     }
 
index 400f36ffd59a6c0411c69564c339158de421f4d3..1bd7060c5d674aee73594303c09f1c9df57cb9e7 100644 (file)
@@ -408,7 +408,7 @@ initPointer (initList * ilist, sym_link *toType)
                        val->type = newLink (DECLARATOR);
                        if (SPEC_SCLS (expr->left->etype) == S_CODE) {
                                DCL_TYPE (val->type) = CPOINTER;
-                               DCL_TYPE (val->type) = port->mem.code_ro;
+                               DCL_PTR_CONST (val->type) = port->mem.code_ro;
                        }
                        else if (SPEC_SCLS (expr->left->etype) == S_XDATA)
                                DCL_TYPE (val->type) = FPOINTER;
index 2792ef48ee309608fca56056e07328998647937c..dd464450e0a82984aa1fd519da6fbad42e67b759 100644 (file)
@@ -2559,6 +2559,11 @@ geniCodeDerefPtr (operand * op,int lvl)
 
   op->isGptr = IS_GENPTR (optype);
 
+  /* if the pointer was declared as a constant */
+  /* then we cannot allow assignment to the derefed */
+  if (IS_PTR_CONST (optype))
+    SPEC_CONST (retype) = 1;
+
   op->isaddr = (IS_PTR (rtype) ||
                IS_STRUCT (rtype) ||
                IS_INT (rtype) ||
index 231e4f65b1b13c1514604bd5c944578cf663b70b..c124e791284f1fd2c6062f708011080ece4b6939 100644 (file)
@@ -348,6 +348,8 @@ pointerTypes (sym_link * ptr, sym_link * type)
      storage class of the type */
   if (IS_SPEC (type))
     {
+      DCL_PTR_CONST (ptr) = SPEC_CONST (type);
+      DCL_PTR_VOLATILE (ptr) = SPEC_VOLATILE (type);
       switch (SPEC_SCLS (type))
        {
        case S_XDATA:
@@ -363,6 +365,7 @@ pointerTypes (sym_link * ptr, sym_link * type)
          DCL_TYPE (ptr) = POINTER;
          break;
        case S_CODE:
+         DCL_PTR_CONST (ptr) = port->mem.code_ro;
          DCL_TYPE (ptr) = CPOINTER;
          break;
        case S_EEPROM:
@@ -455,26 +458,21 @@ addDecl (symbol * sym, int type, sym_link * p)
     }
 
   /* if the type is an unknown pointer and has
-     a tspec then take the const & volatile
+     a tspec then take the storage class const & volatile
      attribute from the tspec & make it those of this
      symbol */
-
   if (p &&
-      IS_DECL (p) &&
-      DCL_TYPE (p) == UPOINTER &&
+      !IS_SPEC (p) &&
+      //DCL_TYPE (p) == UPOINTER &&
       DCL_TSPEC (p))
     {
-      // only for declarators
-      wassert (IS_DECL(sym->type));
-
       if (!IS_SPEC (sym->etype))
        {
          sym->etype = sym->etype->next = newLink (SPECIFIER);
        }
-
       SPEC_SCLS (sym->etype) = SPEC_SCLS (DCL_TSPEC (p));
-      DCL_PTR_CONST (sym->type) = SPEC_CONST (DCL_TSPEC (p));
-      DCL_PTR_VOLATILE (sym->type) = SPEC_VOLATILE (DCL_TSPEC (p));
+      SPEC_CONST (sym->etype) = SPEC_CONST (DCL_TSPEC (p));
+      SPEC_VOLATILE (sym->etype) = SPEC_VOLATILE (DCL_TSPEC (p));
       DCL_TSPEC (p) = NULL;
     }
 
@@ -560,7 +558,14 @@ sym_link *
 mergeSpec (sym_link * dest, sym_link * src, char *name)
 {
   if (!IS_SPEC(dest) || !IS_SPEC(src)) {
+#if 0
+    werror (E_INTERNAL_ERROR, __FILE__, __LINE__, "cannot merge declarator");
+    exit (1);
+#else
     werror (E_SYNTAX_ERROR, yytext);
+    // the show must go on
+    return newIntLink();
+#endif
   }
 
   if (SPEC_NOUN(src)) {
@@ -589,6 +594,17 @@ mergeSpec (sym_link * dest, sym_link * src, char *name)
 
   /* copy all the specifications  */
 
+  // we really should do: 
+#if 0
+  if (SPEC_what(src)) {
+    if (SPEC_what(dest)) {
+      werror(W_DUPLICATE_SPEC, "what");
+    }
+    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;
   SPEC_USIGN (dest) |= SPEC_USIGN (src);