* support/regression/ports/hc08spec.mk: REENTRANT must be reentrant
authormaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 27 Aug 2004 14:06:35 +0000 (14:06 +0000)
committermaartenbrock <maartenbrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 27 Aug 2004 14:06:35 +0000 (14:06 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3452 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCsymt.c
support/regression/ports/hc08/spec.mk

index 0ee5bccb69337ffc13be267d812fac7acc6d6acc..cea93155230f93aa1223b4a61c5a55c18867dae6 100644 (file)
@@ -1249,7 +1249,7 @@ compStructSize (int su, structdef * sdef)
 
         loop = loop->next;
 
-        /* if union then size = sizeof larget field */
+        /* if union then size = sizeof largest field */
         if (su == UNION) {
             /* For UNION, round up after each field */
             sum += ((bitOffset+7)/8);
@@ -1545,6 +1545,23 @@ checkDecl (symbol * sym, int isProto)
   return 0;
 }
 
+/*-------------------------------------------------------------------*/
+/* copyStruct - makes a copy of the struct chain & rets ptr 2 struct */
+/*-------------------------------------------------------------------*/
+structdef *
+copyStruct (structdef * src)
+{
+  structdef *dst = (void *) NULL;
+
+  if (src)
+    {
+      dst = newStruct(src->tag);
+      memcpy(dst, src, sizeof(structdef));      /* copy it */
+      dst->fields = copySymbolChain(src->fields);
+    }
+  return dst;
+}
+
 /*------------------------------------------------------------------*/
 /* copyLinkChain - makes a copy of the link chain & rets ptr 2 head */
 /*------------------------------------------------------------------*/
@@ -1558,6 +1575,17 @@ copyLinkChain (sym_link * p)
   while (curr)
     {
       memcpy (loop, curr, sizeof (sym_link));   /* copy it */
+      if ((curr == p) && IS_STRUCT(curr) && SPEC_STRUCT(curr)->type == STRUCT)
+        {
+          /* if this is a struct specifier which ends */
+          /* with an array of unspecified length then */
+          /* copy the struct and it's fields */
+          struct symbol *field = SPEC_STRUCT(curr)->fields;
+          while (field && field->next)
+            field = field->next; /* find last one */
+          if (field && IS_ARRAY(field->type) && !DCL_ELEM(field->type))
+            SPEC_STRUCT(loop) = copyStruct(SPEC_STRUCT(curr));
+        }
       loop->next = (curr->next ? newLink (curr->next->class) : (void *) NULL);
       loop = loop->next;
       curr = curr->next;
@@ -1566,7 +1594,6 @@ copyLinkChain (sym_link * p)
   return head;
 }
 
-
 /*------------------------------------------------------------------*/
 /* cleanUpBlock - cleansup the symbol table specified for all the   */
 /*                symbols in the given block                        */
index b8cec52f3759fc3bd84f6412c8e11f429b782368..b4d6032a152cc65c9f9203091b9dd89cf62a8e6b 100644 (file)
@@ -4,7 +4,7 @@ UCHC08B = $(SDCC_DIR)/bin/shc08
 
 UCHC08 = $(shell if [ -f $(UCHC08A) ]; then echo $(UCHC08A); else echo $(UCHC08B); fi)
 
-SDCCFLAGS +=-mhc08 --less-pedantic --out-fmt-ihx -DREENTRANT=
+SDCCFLAGS +=-mhc08 --less-pedantic --out-fmt-ihx -DREENTRANT=reentrant
 #SDCCFLAGS +=--less-pedantic -DREENTRANT=reentrant
 
 OBJEXT = .rel