From 8d44dd4952e2e05e2cf5bb36e14078194c5be6d5 Mon Sep 17 00:00:00 2001 From: epetrich Date: Mon, 17 May 2004 07:15:32 +0000 Subject: [PATCH] * src/SDCCval.c (valForArray): applied Maarteen Brock's patch #947682 which fixes bug #543481 * support/regression/tests/bug-751703.c: fixed comments left from a cut and paste error * src/SDCCdwarf2.c (dwCloseFile): don't explicitly close a temp file * src/SDCCdwarf2.c (dwTagFromType): added bitfield support * src/SDCCdwarf2.c (dwWriteSymbolInternal): handle extern within local scopes * src/SDCCdwarf2.c (dwWriteLineNumber): line number deltas are signed * src/SDCCmain.c (processFile, parseCmdLine): non-alphanumeric chars are now changed to underscores in moduleName git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3317 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 14 ++++++++ src/SDCCdwarf2.c | 50 ++++++++++++++++++++++----- src/SDCCmain.c | 13 +++++-- src/SDCCval.c | 2 +- support/regression/tests/bug-751703.c | 7 ++-- 5 files changed, 70 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 253b0b42..78e9989c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2004-05-17 Erik Petrich + + * src/SDCCval.c (valForArray): applied Maarteen Brock's patch #947682 + which fixes bug #543481 + * support/regression/tests/bug-751703.c: fixed comments left from a + cut and paste error + * src/SDCCdwarf2.c (dwCloseFile): don't explicitly close a temp file + * src/SDCCdwarf2.c (dwTagFromType): added bitfield support + * src/SDCCdwarf2.c (dwWriteSymbolInternal): handle extern within local + scopes + * src/SDCCdwarf2.c (dwWriteLineNumber): line number deltas are signed + * src/SDCCmain.c (processFile, parseCmdLine): non-alphanumeric chars + are now changed to underscores in moduleName + 2004-05-15 Jesus Calvino-Fraga * as/mcs51/lkmem.c: better fix for bug #954173 diff --git a/src/SDCCdwarf2.c b/src/SDCCdwarf2.c index 50c24ab3..46c2f6b8 100644 --- a/src/SDCCdwarf2.c +++ b/src/SDCCdwarf2.c @@ -1641,7 +1641,7 @@ dwWriteLineNumber (dwline * lp) curOffset = lp->offset; dwWriteByte (NULL, DW_LNS_advance_line, NULL); - dwWriteULEB128 (NULL, lp->line - 1, NULL); + dwWriteSLEB128 (NULL, lp->line - 1, NULL); curLine = lp->line; dwWriteByte (NULL, DW_LNS_copy, NULL); @@ -1713,7 +1713,7 @@ dwWriteLineNumber (dwline * lp) curOffset = lp->offset; dwWriteByte (NULL, DW_LNS_advance_line, NULL); - dwWriteULEB128 (NULL, deltaLine, NULL); + dwWriteSLEB128 (NULL, deltaLine, NULL); curLine = lp->line; dwWriteByte (NULL, DW_LNS_copy, NULL); @@ -2272,15 +2272,46 @@ dwTagFromType (sym_link * type, dwtag * parent) { dwtag * memtp; dwloc * lp; - + + if (IS_BITFIELD (field->type) && !SPEC_BLEN(field->type)) + { + field = field->next; + continue; + } + memtp = dwNewTag (DW_TAG_member); if (*(field->name)) dwAddTagAttr (memtp, dwNewAttrString (DW_AT_name, field->name)); - subtp = dwTagFromType (field->type, tp); - dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp)); - if (!subtp->parent) - dwAddTagChild (parent, subtp); + if (IS_BITFIELD (field->type)) + { + int blen = SPEC_BLEN (field->type); + int bstr = SPEC_BSTR (field->type); + sym_link * type; + + dwAddTagAttr (memtp, + dwNewAttrConst (DW_AT_byte_size, + (blen+7)/8)); + dwAddTagAttr (memtp, + dwNewAttrConst (DW_AT_bit_size, blen)); + dwAddTagAttr (memtp, + dwNewAttrConst (DW_AT_bit_offset, + ((blen+7) & ~7) + - (blen+bstr))); + if (blen < 8) + type = typeFromStr ("uc"); + else + type = typeFromStr ("ui"); + subtp = dwTagFromType (type, tp); + dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp)); + } + else + { + subtp = dwTagFromType (field->type, tp); + dwAddTagAttr (memtp, dwNewAttrTagRef (DW_AT_type, subtp)); + if (!subtp->parent) + dwAddTagChild (parent, subtp); + } lp = dwNewLoc (DW_OP_plus_uconst, NULL, field->offset); dwAddTagAttr (memtp, @@ -2421,7 +2452,8 @@ int dwCloseFile(void) { if(!dwarf2FilePtr) return 0; - fclose(dwarf2FilePtr); + /* Don't explicitly close the file; this will be done automatically */ + dwarf2FilePtr = NULL; return 1; } @@ -2516,7 +2548,7 @@ dwWriteSymbolInternal (symbol *sym) dwattr * funcap; int inregs = 0; - if (!sym->level) + if (!sym->level || IS_EXTERN (sym->etype)) scopetp = dwRootTag; else { diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 3231e34c..92e08452 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -58,8 +58,10 @@ char *fullDstFileName; /* full name for the output file; */ char *dstFileName; /* destination file name without extension */ char *dstPath = ""; /* path for the output files; */ /* "" is equivalent with cwd */ -char *moduleName; /* module name is source file without path and extension */ +char *moduleNameBase; /* module name base is source file without path and extension */ /* can be NULL while linking without compiling */ +char *moduleName; /* module name is same as module name base, but with all */ + /* non-alphanumeric characters replaced with underscore */ int currRegBank = 0; int RegBankUsed[4] = {1, 0, 0, 0}; /*JCF: Reg Bank 0 used by default*/ struct optimize optimize; @@ -606,7 +608,12 @@ processFile (char *s) fext--; } #endif + moduleNameBase = Safe_strdup ( fext ); moduleName = Safe_strdup ( fext ); + + for (fext = moduleName; *fext; fext++) + if (!isalnum (*fext)) + *fext = '_'; return; } @@ -1235,11 +1242,11 @@ parseCmdLine (int argc, char **argv) /* use the modulename from the C-source */ if (fullSrcFileName) { - size_t bufSize = strlen (dstPath) + strlen (moduleName) + 1; + size_t bufSize = strlen (dstPath) + strlen (moduleNameBase) + 1; dstFileName = Safe_alloc (bufSize); strncpyz (dstFileName, dstPath, bufSize); - strncatz (dstFileName, moduleName, bufSize); + strncatz (dstFileName, moduleNameBase, bufSize); } /* use the modulename from the first object file */ else if ((s = peekSet(relFilesSet)) != NULL) diff --git a/src/SDCCval.c b/src/SDCCval.c index bbf475c1..96c962a5 100644 --- a/src/SDCCval.c +++ b/src/SDCCval.c @@ -1699,7 +1699,7 @@ valForArray (ast * arrExpr) DCL_TYPE (val->type) = EEPPOINTER; else DCL_TYPE (val->type) = POINTER; - val->type->next = arrExpr->left->ftype; + val->type->next = arrExpr->left->ftype->next; val->etype = getSpec (val->type); return val; } diff --git a/support/regression/tests/bug-751703.c b/support/regression/tests/bug-751703.c index 49f84e76..3f89a316 100644 --- a/support/regression/tests/bug-751703.c +++ b/support/regression/tests/bug-751703.c @@ -1,9 +1,10 @@ /* bug-751703.c - If test_index is char, loses high bit when indexes table - workaround is to use [(unsigned int) test_index] + Make sure extern within local scope binds to global + scope and is not optimized inappropriately. */ -#include + +#include "testfwk.h" int x = 1; int y = 2; -- 2.30.2