From: sandeep Date: Sun, 18 Feb 2001 01:08:24 +0000 (+0000) Subject: Fixed 3 bugs X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=49529cf44a99cf7cfa3fc927c43c4549ca876c5c;p=fw%2Fsdcc Fixed 3 bugs a) constant case label problem (eg -0x01) b) constant pointer semantics c) scope of local variables git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@622 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index 030946d2..b8e599e0 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2213,7 +2213,7 @@ decorateType (ast * tree) /*------------------------------------------------------------------*/ /*----------------------------*/ - /* address dereference */ +/* address dereference */ /*----------------------------*/ case '*': /* can be unary : if right is null then unary operation */ if (!tree->right) @@ -2234,7 +2234,7 @@ decorateType (ast * tree) TETYPE (tree) = getSpec (TTYPE (tree)); tree->args = tree->left->args; tree->hasVargs = tree->left->hasVargs; - SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE (tree)); + SPEC_CONST (TETYPE (tree)) = DCL_PTR_CONST (LTYPE(tree)); return tree; } @@ -2387,6 +2387,7 @@ decorateType (ast * tree) tree->opval.val = valUnaryPM (valFromType (LETYPE (tree))); tree->left = NULL; TETYPE (tree) = TTYPE (tree) = tree->opval.val->type; + SPEC_USIGN(TETYPE(tree)) = 0; return tree; } LRVAL (tree) = 1; @@ -2950,9 +2951,11 @@ decorateType (ast * tree) LTYPE (tree)); RRVAL (tree) = 1; LLVAL (tree) = 1; - if (!tree->initMode && IS_CONSTANT (LETYPE (tree))) - werror (E_CODE_WRITE, " "); - + if (!tree->initMode ) { + if (IS_CONSTANT (LETYPE (tree))) { + werror (E_CODE_WRITE, " "); + } + } if (LRVAL (tree)) { werror (E_LVALUE_REQUIRED, "="); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index a537c705..e5fc5a66 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -197,7 +197,7 @@ findSymWithLevel (bucket ** stab, symbol * sym) if (bp->level && bp->level == sym->level && bp->block == sym->block) return (bp->sym); /* if levels don't match then we are okay */ - if (bp->level && bp->level != sym->level) + if (bp->level && bp->level != sym->level && bp->block <= sym->block) return (bp->sym); /* if this is a global variable then we are ok too */ if (bp->level == 0) @@ -1785,6 +1785,8 @@ printTypeChain (sym_link * type, FILE * of) fprintf (of, "volatile "); if (SPEC_USIGN (type)) fprintf (of, "unsigned "); + if (SPEC_CONST (type)) + fprintf (of, "const "); switch (SPEC_NOUN (type)) { diff --git a/src/SDCCsymt.h b/src/SDCCsymt.h index 172497b1..69184e9d 100644 --- a/src/SDCCsymt.h +++ b/src/SDCCsymt.h @@ -326,8 +326,7 @@ symbol; #define IS_LONG(x) (IS_SPEC(x) && x->select.s._long) #define IS_SHORT(x) (IS_SPEC(x) && x->select.s._short) #define IS_TYPEDEF(x)(IS_SPEC(x) && x->select.s._typedef) -#define IS_CONSTANT(x) (IS_SPEC(x) && (x->select.s.sclass == S_CONSTANT ||\ - x->select.s._const == 1)) +#define IS_CONSTANT(x) (IS_SPEC(x) && ( x->select.s._const == 1)) #define IS_STRUCT(x) (IS_SPEC(x) && x->select.s.noun == V_STRUCT) #define IS_ABSOLUTE(x) (IS_SPEC(x) && x->select.s._absadr ) #define IS_REGISTER(x) (IS_SPEC(x) && SPEC_SCLS(x) == S_REGISTER)