* src/SDCCval.c (valForArray): applied Maarteen Brock's patch #947682
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 May 2004 07:15:32 +0000 (07:15 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 17 May 2004 07:15:32 +0000 (07:15 +0000)
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
src/SDCCdwarf2.c
src/SDCCmain.c
src/SDCCval.c
support/regression/tests/bug-751703.c

index 253b0b42080ae4bcbe63f9ab812d6c451aef43ba..78e9989c36d3bca94c1104da20ac249e1730b6d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2004-05-17 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * 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 <jesusc AT ece.ubc.ca>
 
        * as/mcs51/lkmem.c: better fix for bug #954173
index 50c24ab35ec7a22aca0b94146d029151b2208d95..46c2f6b86718bec836f8983e7589b65ea5ac5b1d 100644 (file)
@@ -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
     {
index 3231e34c047ce37bfe4d25821df58926b9eea28b..92e084521b693b4b46525b261cad0a722107108e 100644 (file)
@@ -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)
index bbf475c15c7c29d6cf192fb274b32a3ab40a12d1..96c962a5168666fb795e20001f2d3c4ac515eb31 100644 (file)
@@ -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;
 }
index 49f84e76cb2b249ed59a219db7344d26829787cc..3f89a31623db1fdd715b53c35f0d9da242fc2b2d 100644 (file)
@@ -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 <testfwk.h>
+
+#include "testfwk.h"
 
 int x = 1;
 int y = 2;