From: johanknol Date: Sun, 3 Mar 2002 17:45:50 +0000 (+0000) Subject: Changelog:1.102 I hate to repeat myself ... X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=1863c6d39345b934ebcd64b9163e2017f40cd92a;p=fw%2Fsdcc Changelog:1.102 I hate to repeat myself ... git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1989 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/src/SDCCast.c b/src/SDCCast.c index a647dcdd..e66872b3 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -367,6 +367,7 @@ resolveSymbols (ast * tree) if (tree == NULL) return tree; +#if 0 /* print the line */ /* if not block & function */ if (tree->type == EX_OP && @@ -377,6 +378,7 @@ resolveSymbols (ast * tree) filename = tree->filename; lineno = tree->lineno; } +#endif /* make sure we resolve the true & false labels for ifx */ if (tree->type == EX_OP && tree->opval.op == IFX) @@ -1085,6 +1087,16 @@ gatherAutoInit (symbol * autoChain) /* if there is an initial value */ if (sym->ival && SPEC_SCLS (sym->etype) != S_CODE) { + initList *ilist=sym->ival; + + while (ilist->type == INIT_DEEP) { + ilist = ilist->init.deep; + } + + /* update lineno for error msg */ + lineno=sym->lineDef; + setAstLineno (ilist->init.node, lineno); + if (IS_AGGREGATE (sym->type)) { work = initAggregates (sym, sym->ival, NULL); } else { @@ -1095,8 +1107,10 @@ gatherAutoInit (symbol * autoChain) work = newNode ('=', newAst_VALUE (symbolVal (sym)), list2expr (sym->ival)); } - + + // just to be sure setAstLineno (work, sym->lineDef); + sym->ival = NULL; if (init) init = newNode (NULLOP, init, work); @@ -1849,6 +1863,7 @@ decorateType (ast * tree) tree->decorated = 1; +#if 0 /* print the line */ /* if not block & function */ if (tree->type == EX_OP && @@ -1859,6 +1874,7 @@ decorateType (ast * tree) filename = tree->filename; lineno = tree->lineno; } +#endif /* if any child is an error | this one is an error do nothing */ if (tree->isError || @@ -2454,7 +2470,7 @@ decorateType (ast * tree) LRVAL (tree) = RRVAL (tree) = 1; /* if the left is a pointer */ - if (IS_PTR (LTYPE (tree))) + if (IS_PTR (LTYPE (tree)) || IS_ARRAY (LTYPE (tree))) TETYPE (tree) = getSpec (TTYPE (tree) = LTYPE (tree)); else diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 7bb11bef..b0860486 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -329,11 +329,23 @@ initPointer (initList * ilist, sym_link *toType) if ((val = constExprValue (expr, FALSE))) return val; + /* ( ptr + constant ) */ + if (IS_AST_OP (expr) && + (expr->opval.op == '+' || expr->opval.op == '-') && + IS_AST_SYM_VALUE (expr->left) && + (IS_ARRAY(expr->left->ftype) || IS_PTR(expr->left->ftype)) && + compareType(toType, expr->left->ftype) && + IS_AST_LIT_VALUE (expr->right)) { + return valForCastAggr (expr->left, expr->left->ftype, + expr->right, + expr->opval.op); + } + /* (char *)&a */ if (IS_AST_OP(expr) && expr->opval.op==CAST && IS_AST_OP(expr->right) && expr->right->opval.op=='&') { if (compareType(toType, expr->left->ftype)!=1) { - werror (E_INIT_WRONG); + werror (W_INIT_WRONG); printFromToType(expr->left->ftype, toType); } // skip the cast ??? @@ -401,7 +413,6 @@ initPointer (initList * ilist, sym_link *toType) expr->right, expr->opval.op); } - /* case 4. (char *)(array type) */ if (IS_CAST_OP(expr) && IS_AST_SYM_VALUE (expr->right) && IS_ARRAY(expr->right->ftype)) { @@ -427,7 +438,7 @@ initPointer (initList * ilist, sym_link *toType) return val; } wrong: - werror (E_INIT_WRONG); + werror (E_INCOMPAT_PTYPES); return NULL; } @@ -493,12 +504,8 @@ pointerTypeToGPByte (const int p_type, const char *iname, const char *oname) case POINTER: return 0; case GPOINTER: - /* hack - if we get a generic pointer, we just assume - * it's an FPOINTER (i.e. in XDATA space). - */ werror (E_CANNOT_USE_GENERIC_POINTER, iname, oname); exit (1); - // fall through case FPOINTER: return 1; case CPOINTER: @@ -971,7 +978,7 @@ printIvalPtr (symbol * sym, sym_link * type, initList * ilist, FILE * oFile) /* check the type */ if (compareType (type, val->type) == 0) { - werror (E_INIT_WRONG); + werror (W_INIT_WRONG); printFromToType (val->type, type); } diff --git a/support/Util/SDCCerr.c b/support/Util/SDCCerr.c index e8b25529..5aac4a73 100644 --- a/support/Util/SDCCerr.c +++ b/support/Util/SDCCerr.c @@ -87,7 +87,7 @@ struct "storage class not allowed for automatic variable '%s' in reentrant function unless static" }, { E_AUTO_ABSA, ERROR_LEVEL_ERROR, "absolute address not allowed for automatic var '%s' in reentrant function " }, -{ E_INIT_WRONG, ERROR_LEVEL_ERROR, +{ W_INIT_WRONG, ERROR_LEVEL_WARNING, "Initializer different levels of indirections" }, { E_FUNC_REDEF, ERROR_LEVEL_ERROR, "Function name '%s' redefined " }, diff --git a/support/Util/SDCCerr.h b/support/Util/SDCCerr.h index f56b728a..fcd04ea8 100644 --- a/support/Util/SDCCerr.h +++ b/support/Util/SDCCerr.h @@ -33,7 +33,7 @@ SDCCERR - SDCC Standard error handler #define W_INIT_IGNORED 15 /* initialiser ignored */ #define E_AUTO_ASSUMED 16 /* sclass auto assumed */ #define E_AUTO_ABSA 17 /* abs addr for auto var*/ -#define E_INIT_WRONG 18 /* initializer type != */ +#define W_INIT_WRONG 18 /* initializer type != */ #define E_FUNC_REDEF 19 /* func name redefined */ #define E_ID_UNDEF 20 /* identifer undefined */ #define W_STACK_OVERFLOW 21 /* stack overflow */ diff --git a/support/regression/tests/bug-524691.c b/support/regression/tests/bug-524691.c index a4442382..8b0a3db7 100644 --- a/support/regression/tests/bug-524691.c +++ b/support/regression/tests/bug-524691.c @@ -2,6 +2,12 @@ */ #include +#if defined __mcs51 || defined __ds390 || defined __xa51 +#define XDATA xdata +#else +#define XDATA +#endif + typedef unsigned int UINT; typedef struct _HeapEntryState @@ -43,9 +49,9 @@ void testDivByZero(void) { HeapEntryState aStates[] = { - { (void *)1, 0 } + { (void XDATA *)1, 0 } }; - void *p = (void *)0x1234; + void *p = (void XDATA *)0x1234; ASSERT(_getHeapEntryState(p, aStates, 1) == NULL);