aboutsummaryrefslogtreecommitdiffhomepage
path: root/c
diff options
context:
space:
mode:
Diffstat (limited to 'c')
-rw-r--r--c/c.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/c/c.c b/c/c.c
index 36ef6d5..75c9795 100644
--- a/c/c.c
+++ b/c/c.c
@@ -231,13 +231,21 @@ redeclarationok(const struct decl *old, const struct decl *new)
switch (old->scls) {
case SCSTATIC:
case SCEXTERN:
- if (old->ty.t == TYARRAY && new->ty.t == TYARRAY
+ if (old->ty.bits == new->ty.bits) return 1;
+ if (old->ty.t != new->ty.t) return 0;
+ if (old->ty.t == TYARRAY /* allow 'int x[]; int x[100];' */
&& typechild(old->ty).bits == typechild(new->ty).bits
&& (isincomplete(old->ty) || isincomplete(new->ty)))
{
return 1;
}
- /*fallthru*/
+ if (old->ty.t == TYFUNC /* allow 'int f(); int f(int);' (some K&R) */
+ && typedata[old->ty.dat].ret.bits == typedata[new->ty.dat].ret.bits
+ && (typedata[old->ty.dat].kandr || typedata[new->ty.dat].kandr))
+ {
+ return 1;
+ }
+ return 0;
case SCTYPEDEF:
return old->ty.bits == new->ty.bits;
}