From: bernhardheld Date: Thu, 24 Nov 2005 15:27:36 +0000 (+0000) Subject: * src/SDCCsymt.c (copyLinkChain): fixed bug 770487, copy structdef and fields-list too X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=e18eec8c87d6b50be0e894469ec64651b31e2b07;p=fw%2Fsdcc * src/SDCCsymt.c (copyLinkChain): fixed bug 770487, copy structdef and fields-list too * src/SDCCast.c (createIvalArray): removed obsolete comment git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3979 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 2d2d55c1..85785c48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-24 Bernhard Held + + * src/SDCCsymt.c (copyLinkChain): fixed bug 770487, copy structdef + and fields-list too + * src/SDCCast.c (createIvalArray): removed obsolete comment + 2005-11-24 Borut Razem * sdcc/device/lib/Makefile.in: remove all unnecessary files, 2nd try... diff --git a/src/SDCCast.c b/src/SDCCast.c index d82a0719..83214a5a 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -991,7 +991,6 @@ createIvalArray (ast * sym, sym_link * type, initList * ilist) /* if we have not been given a size */ if (!DCL_ELEM (type)) { - /* but this still updates the typedef instead of the instance ! see bug 770487 */ DCL_ELEM (type) = size; } diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 1f24805d..7d10d227 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -328,6 +328,20 @@ newStruct (char *tag) return s; } +/*------------------------------------------------------------------*/ +/* copyStruct - copies a structdef including the fields-list */ +/*------------------------------------------------------------------*/ +static structdef * +copyStruct (structdef *src) +{ + structdef *dest; + + dest = newStruct (""); + memcpy (dest, src, sizeof (structdef)); + dest->fields = copySymbolChain (src->fields); + return dest; +} + /*------------------------------------------------------------------*/ /* sclsFromPtr - Return the storage class a pointer points into. */ /* S_FIXED is returned for generic pointers or other */ @@ -1630,6 +1644,8 @@ copyLinkChain (sym_link * p) while (curr) { memcpy (loop, curr, sizeof (sym_link)); /* copy it */ + if (IS_STRUCT (loop)) + SPEC_STRUCT (loop) = copyStruct (SPEC_STRUCT (loop)); loop->next = (curr->next ? newLink (curr->next->class) : (void *) NULL); loop = loop->next; curr = curr->next;