diff options
Diffstat (limited to 'src/compiler/decl.zc')
| -rw-r--r-- | src/compiler/decl.zc | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/compiler/decl.zc b/src/compiler/decl.zc index 1c72ba0..dfcff4f 100644 --- a/src/compiler/decl.zc +++ b/src/compiler/decl.zc @@ -329,8 +329,8 @@ int fndef(int chk, int rty, int ret, int n) { next(); } pnoffs[np] = toff; pnplaces[np] = tpack(); rs_note(RS_PARAM, toff); - if (!pk && !t && tk == T_ID && istypename(tv)) amb = amb | (1 << np); // int f(int): a name, or a type if this is a prototype - if (pk && tk == T_OP && (tv == s_comma || tv == s_rp)) { pn[np] = 0; nonm = 1; } else pn[np] = name(); // int f(int*, int): a prototype's parameters may be unnamed + if (pk && (is_op(s_comma) || is_op(s_rp))) { pn[np] = 0; nonm = 1; } // int f(int*, int): a prototype's parameters may be unnamed + else { if (!pk && !t && istypename(tv)) amb = amb | (1 << np); pn[np] = name(); } // int f(int): a name, or a type if this is a prototype if (o3f && pty[np] == tword) serr("o3 parameters need a type"); if (np >= 12 && t) die("only the first 12 parameters can be tagged"); pt[np] = t; @@ -341,13 +341,12 @@ int fndef(int chk, int rty, int ret, int n) { } } expect(s_rp); - if (is_op(s_semi)) { // a prototype: a lone type name is an unnamed parameter of that type (b.2.13) - i = 0; - while (i < np) { - if (((amb >> i) & 1) && pn[i]) { t = lookup(pn[i]); if (t >= 0 && skind[t] == K_TYPE) { pty[i] = sval[t]; typed = 1; } } - i++; - } - } else if (nonm) serr("a parameter needs a name"); + if (!is_op(s_semi)) { if (nonm) serr("a parameter needs a name"); amb = 0; } + i = 0; + while (amb) { // a prototype: a lone type name is an unnamed parameter of that type (b.2.13) + if (amb & 1) { t = lookup(pn[i]); if (t >= 0 && skind[t] == K_TYPE) { pty[i] = sval[t]; typed = 1; } } + amb = amb >> 1; i++; + } sig = ret + np + np + tags * 64; if ((sflag[s] & F_SIG) && !(sflag[s] & F_PRE)) { if (ssig[s] != sig) serrn(n, "doesn't match its earlier declaration"); |
