From 59649e00927d0db09488038b2eb7543bbe0f2214 Mon Sep 17 00:00:00 2001 From: epetrich Date: Sat, 13 Dec 2003 06:56:07 +0000 Subject: [PATCH] * src/SDCCicode.c (geniCodeAdd), * src/SDCCast.c (decorateType): fixed bug #857753 (need to be careful with valFromType if type might be a pointer and host is big endian). * src/SDCCast.c (decorateType): unary plus compatible with all arithmetic types, not just integer types. * src/SDCCsymt.c (addSymChain): clarified error message when symbol is multiply defined with mismatching "at" address. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3050 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 10 ++++++++++ src/SDCCast.c | 14 +++++++------- src/SDCCicode.c | 8 ++++---- src/SDCCsymt.c | 27 ++++++++++++++++++++++++++- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4178725c..236d8ee3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-12-13 Erik Petrich + + * src/SDCCicode.c (geniCodeAdd), + * src/SDCCast.c (decorateType): fixed bug #857753 (need to be careful + with valFromType if type might be a pointer and host is big endian). + * src/SDCCast.c (decorateType): unary plus compatible with all arithmetic + types, not just integer types. + * src/SDCCsymt.c (addSymChain): clarified error message when symbol is + multiply defined with mismatching "at" address. + 2003-12-12 Erik Petrich * src/ds390/main.c (PORT tininative_port): fixed bug #858416 diff --git a/src/SDCCast.c b/src/SDCCast.c index 3ad20980..0a289dbe 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2776,7 +2776,7 @@ decorateType (ast * tree) /* if unary plus */ if (!tree->right) { - if (!IS_INTEGRAL (LTYPE (tree))) + if (!IS_ARITHMETIC (LTYPE (tree))) { werror (E_UNARY_OP, '+'); goto errorTreeReturn; @@ -3249,7 +3249,7 @@ decorateType (ast * tree) tree->opval.val = valCastLiteral ( LTYPE (tree), element->offset - + floatFromVal (valFromType (RETYPE (tree->right->left->left))) + + floatFromVal (valFromType (RTYPE (tree->right->left->left))) ); TTYPE (tree) = tree->opval.val->type; @@ -3285,7 +3285,7 @@ decorateType (ast * tree) sym->cdef = 1; sym->isref = 1; SPEC_STAT (sym->etype) = 1; - SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RETYPE (tree))); + SPEC_ADDR(sym->etype) = floatFromVal (valFromType (RTYPE (tree))); SPEC_ABSA(sym->etype) = 1; addSym (SymbolTab, sym, sym->name, 0, 0, 0); allocGlobal (sym); @@ -3303,7 +3303,7 @@ decorateType (ast * tree) tree->type = EX_VALUE; tree->opval.val = valCastLiteral (LTYPE (tree), - floatFromVal (valFromType (RETYPE (tree)))); + floatFromVal (valFromType (RTYPE (tree)))); TTYPE (tree) = tree->opval.val->type; tree->left = NULL; tree->right = NULL; @@ -3348,8 +3348,8 @@ decorateType (ast * tree) IS_LITERAL (LTYPE (tree))) { tree->type = EX_VALUE; - tree->opval.val = valLogicAndOr (valFromType (LETYPE (tree)), - valFromType (RETYPE (tree)), + tree->opval.val = valLogicAndOr (valFromType (LTYPE (tree)), + valFromType (RTYPE (tree)), tree->opval.op); tree->right = tree->left = NULL; TETYPE (tree) = getSpec (TTYPE (tree) = @@ -3390,7 +3390,7 @@ decorateType (ast * tree) if (compareType (LTYPE (tree), RTYPE (tree)) == 0) { werror (E_COMPARE_OP); - fprintf (stderr, "comparring type "); + fprintf (stderr, "comparing type "); printTypeChain (LTYPE (tree), stderr); fprintf (stderr, "to type "); printTypeChain (RTYPE (tree), stderr); diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 53efa92c..9637d52d 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -2176,11 +2176,11 @@ geniCodeAdd (operand * left, operand * right, int lvl) /* if the right side is LITERAL zero */ /* return the left side */ - if (IS_LITERAL (retype) && right->isLiteral && !floatFromVal (valFromType (retype))) + if (IS_LITERAL (retype) && right->isLiteral && !floatFromVal (valFromType (rtype))) return left; /* if left is literal zero return right */ - if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (letype))) + if (IS_LITERAL (letype) && left->isLiteral && !floatFromVal (valFromType (ltype))) return right; /* if left is a pointer then size */ @@ -2202,8 +2202,8 @@ geniCodeAdd (operand * left, operand * right, int lvl) /* if they are both literals then we know */ if (IS_LITERAL (letype) && IS_LITERAL (retype) && left->isLiteral && right->isLiteral) - return operandFromValue (valPlus (valFromType (letype), - valFromType (retype))); + return operandFromValue (valPlus (valFromType (ltype), + valFromType (rtype))); ic = newiCode ('+', left, right); diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index f68a60e5..14bcaee6 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -1000,6 +1000,23 @@ addSymChain (symbol * symHead) DCL_ELEM(csym->type) = DCL_ELEM(sym->type); } + #if 0 + /* If only one of the definitions used the "at" keyword, copy */ + /* the address to the other. */ + if (IS_SPEC(csym->etype) && SPEC_ABSA(csym->etype) + && IS_SPEC(sym->etype) && !SPEC_ABSA(sym->etype)) + { + SPEC_ABSA (sym->etype) = 1; + SPEC_ADDR (sym->etype) = SPEC_ADDR (csym->etype); + } + if (IS_SPEC(csym->etype) && !SPEC_ABSA(csym->etype) + && IS_SPEC(sym->etype) && SPEC_ABSA(sym->etype)) + { + SPEC_ABSA (csym->etype) = 1; + SPEC_ADDR (csym->etype) = SPEC_ADDR (sym->etype); + } + #endif + error = 0; if (csym->ival && sym->ival) error = 1; @@ -1012,7 +1029,15 @@ addSymChain (symbol * symHead) werror (E_EXTERN_MISMATCH, sym->name); else werror (E_DUPLICATE, sym->name); - printFromToType (csym->type, sym->type); + fprintf (stderr, "from type '"); + printTypeChain (csym->type, stderr); + if (IS_SPEC (csym->etype) && SPEC_ABSA (csym->etype)) + fprintf(stderr, " at 0x%x", SPEC_ADDR (csym->etype)); + fprintf (stderr, "'\nto type '"); + printTypeChain (sym->type, stderr); + if (IS_SPEC (sym->etype) && SPEC_ABSA (sym->etype)) + fprintf(stderr, " at 0x%x", SPEC_ADDR (sym->etype)); + fprintf (stderr, "'\n"); continue; } -- 2.30.2