diff options
| author | 2025-12-03 17:30:20 +0100 | |
|---|---|---|
| committer | 2025-12-03 17:30:20 +0100 | |
| commit | acfb93a96fde1263e8bfd7580668efe1aee54678 (patch) | |
| tree | 907684957fe92dffd78e026c4c3bca1055076f87 /c | |
| parent | bfd58e2c515e8c360fda4bee3d0702c60d92ebf0 (diff) | |
c: allow redeclaration with K&R and non K&R prototypes
Diffstat (limited to 'c')
| -rw-r--r-- | c/c.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -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; } |