X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCsymt.c;h=c65c3e2f965da328d1853bce5a27131d975d9ff4;hb=f96e7d4df901d66ed8f5025c20cc5976115d0a54;hp=eba05f5a30e72bd66415023b7f2aead7706c8a08;hpb=8b40d36f8024802d5d99882bd58491130d260b38;p=fw%2Fsdcc diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index eba05f5a..c65c3e2f 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -438,6 +438,7 @@ pointerTypes (sym_link * ptr, sym_link * type) void addDecl (symbol * sym, int type, sym_link * p) { + static sym_link *empty = NULL; sym_link *head; sym_link *tail; sym_link *t; @@ -445,6 +446,9 @@ addDecl (symbol * sym, int type, sym_link * p) 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) { @@ -464,28 +468,28 @@ addDecl (symbol * sym, int type, sym_link * 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