From: johanknol Date: Mon, 17 Mar 2003 15:44:27 +0000 (+0000) Subject: Cleaned up some more mess. Everything should be the same now as on the 12th X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=3096c622c84deebb7d4147ff68f01f80cfe567d8;p=fw%2Fsdcc Cleaned up some more mess. Everything should be the same now as on the 12th git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2397 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCC.y b/src/SDCC.y index c558c6c7..25ba60f9 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -603,9 +603,6 @@ type_specifier2 | CODE { $$ = newLink (SPECIFIER) ; SPEC_SCLS($$) = S_CODE ; - if (port->mem.code_ro) { - SPEC_CONST($$) = 1; - } } | EEPROM { $$ = newLink (SPECIFIER) ; diff --git a/src/SDCCast.c b/src/SDCCast.c index 0024cff3..a2066a19 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -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)) diff --git a/src/SDCCcse.c b/src/SDCCcse.c index cde6f7fd..bc784a21 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -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; } diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 400f36ff..1bd7060c 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -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; diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 2792ef48..dd464450 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -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) || diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 231e4f65..c124e791 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -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);