From fc41563d33a3da06336117a698f00206800e7827 Mon Sep 17 00:00:00 2001 From: epetrich Date: Wed, 26 Nov 2003 18:19:53 +0000 Subject: [PATCH] * src/SDCCast.c (decorateType): disabled a transformation I added in revision 1.188 (access to fields of a structure at an absolute address); it breaks with bitfields, extern declarations, and gcse analysis. * src/SDCCopt.c (isLocalWithoutDef): if ADDRESS_OF applied to a symbol, it could be assigned through a pointer, so don't complain. * src/SDCCast.c (astErrors), * src/SDCCast.h, * src/SDCCglue.c (emitRegularMap): fixed bug #847813 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3030 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 11 +++++++++++ src/SDCCast.c | 27 ++++++++++++++++++++++++++- src/SDCCast.h | 1 + src/SDCCglue.c | 3 ++- src/SDCCopt.c | 3 +++ 5 files changed, 43 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82c46439..5fdaf8cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2003-11-26 Erik Petrich + + * src/SDCCast.c (decorateType): disabled a transformation I added in + revision 1.188 (access to fields of a structure at an absolute address); + it breaks with bitfields, extern declarations, and gcse analysis. + * src/SDCCopt.c (isLocalWithoutDef): if ADDRESS_OF applied to a symbol, it + could be assigned through a pointer, so don't complain. + * src/SDCCast.c (astErrors), + * src/SDCCast.h, + * src/SDCCglue.c (emitRegularMap): fixed bug #847813 + 2003-11-26 Vangelis Rokas * src/pic16/main.c (_pic16_genIVT): fixed interrupt vector table diff --git a/src/SDCCast.c b/src/SDCCast.c index fcf18e22..a0fe5960 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -2242,6 +2242,10 @@ decorateType (ast * tree) break; } + /* This breaks with extern declarations, bitfields, and perhaps other */ + /* cases (gcse). Let's leave this optimization disabled for now and */ + /* ponder if there's a safe way to do this. -- EEP */ + #if 0 if (IS_ADDRESS_OF_OP (tree->left) && IS_AST_SYM_VALUE(tree->left->left) && SPEC_ABSA (AST_SYMBOL (tree->left->left)->etype)) { @@ -2274,7 +2278,8 @@ decorateType (ast * tree) tree->left = NULL; tree->right = NULL; } - + #endif + return tree; /*------------------------------------------------------------------*/ @@ -5696,3 +5701,23 @@ void PA(ast *t) { ast_print(t,stdout,0); } + + + +/*-----------------------------------------------------------------*/ +/* astErrors : returns non-zero if errors present in tree */ +/*-----------------------------------------------------------------*/ +int astErrors(ast *t) +{ + int errors=0; + + if (t) + { + if (t->isError) + errors++; + errors += astErrors(t->left); + errors += astErrors(t->right); + } + + return errors; +} diff --git a/src/SDCCast.h b/src/SDCCast.h index 2054e1df..589141f9 100644 --- a/src/SDCCast.h +++ b/src/SDCCast.h @@ -211,6 +211,7 @@ bool hasSEFcalls (ast *); void addSymToBlock (symbol *, ast *); void freeStringSymbol(symbol *); DEFSETFUNC(resetParmKey); +int astErrors(ast *); // exported variables extern set *operKeyReset; diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 5a12ac3b..4b636021 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -321,7 +321,8 @@ emitRegularMap (memmap * map, bool addPublics, bool arFlag) // but try to do it anyway } allocInfo = 0; - eBBlockFromiCode (iCodeFromAst (ival)); + if (!astErrors(ival)) + eBBlockFromiCode (iCodeFromAst (ival)); allocInfo = 1; } } diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 677f72b9..1861ef2c 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -572,6 +572,9 @@ isLocalWithoutDef (symbol * sym) if (IS_AGGREGATE (sym->type)) return 0; + if (sym->addrtaken) + return 0; + return !sym->defs; } -- 2.39.5