return merge_specs(l1, l2);
}
+/*
+ * Mask to clear the type/storage specifier bits on one side of the comparison
+ * to ensure that only function specifiers and qualifiers comapare equal below.
+ */
+#define SPEC_DUP_MASK (~(CDECL_SPEC_TYPE|CDECL_SPEC_STOR|0u))
+
/*
* C allows declaration specifiers to appear in any order, and allows arbitrary
* repetition of some kinds of specifiers. Normalize the specifier lists by
for (c = specs; c; c = c->next)
count++;
- specs = sort_specs(specs, count);
- for (c = specs, l = NULL; c; l = c, c = c->next) {
- if (!(c->type & (CDECL_SPEC_QUAL|CDECL_SPEC_FUNC)))
- continue;
+ if (!(l = specs = sort_specs(specs, count)))
+ return NULL;
- if (l && l->type == c->type) {
+ while ((c = l->next)) {
+ if ((l->type & SPEC_DUP_MASK) == c->type) {
l->next = c->next;
free(c);
- c = l;
+ } else {
+ l = c;
}
}