2006-12-06 Maarten Brock <sourceforge.brock AT dse.nl>
+ * src/SDCCsymt.c (addDecl): fixed bug 1609244
* src/SDCCmain.c (linkEdit): fixed bug 1609279
+ * doc/sdccman.lyx,
* .version: bumped to 2.6.2 because a) it's been a while
b) the linker sources have moved c) the preprocessor is upgraded
void
addDecl (symbol * sym, int type, sym_link * p)
{
+ static sym_link *empty = NULL;
sym_link *head;
sym_link *tail;
sym_link *t;
if (getenv("SDCC_DEBUG_FUNCTION_POINTERS"))
fprintf (stderr, "SDCCsymt.c:addDecl(%s,%d,%p)\n", sym->name, type, p);
+ if (empty == NULL)
+ empty = newLink(SPECIFIER);
+
/* if we are passed a link then set head & tail */
if (p)
{
sym->type = head;
sym->etype = tail;
}
+ else if (IS_SPEC (sym->etype) && IS_SPEC (head) && head == tail)
+ {
+ sym->etype = mergeSpec (sym->etype, head, sym->name);
+ }
+ else if (IS_SPEC (sym->etype) && !IS_SPEC (head) && head == tail)
+ {
+ t = sym->type;
+ while (t->next != sym->etype)
+ t = t->next;
+ t->next = head;
+ tail->next = sym->etype;
+ }
+ else if (IS_FUNC (sym->type) && IS_SPEC (sym->type->next) &&
+ !memcmp(sym->type->next, empty, sizeof(sym_link)))
+ {
+ sym->type->next = head;
+ sym->etype = tail;
+ }
else
{
- if (IS_SPEC (sym->etype) && IS_SPEC (head) && head == tail)
- {
- sym->etype = mergeSpec (sym->etype, head, sym->name);
- }
- else
- {
- if (IS_SPEC (sym->etype) && !IS_SPEC (head) && head == tail)
- {
- t = sym->type;
- while (t->next != sym->etype)
- t = t->next;
- t->next = head;
- tail->next = sym->etype;
- }
- else
- {
- sym->etype->next = head;
- sym->etype = tail;
- }
- }
+ sym->etype->next = head;
+ sym->etype = tail;
}
/* if the type is an unknown pointer and has