diff options
| -rw-r--r-- | src/tools/zc0.c | 5 | ||||
| -rw-r--r-- | tests/conformance/5-declarations/fn_param_tag_u_rejected.zc | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/tools/zc0.c b/src/tools/zc0.c index fc60ddf..20dcbf9 100644 --- a/src/tools/zc0.c +++ b/src/tools/zc0.c @@ -831,7 +831,10 @@ static void fndef(int ret, int rstr) /* rstr: the return type is bstr */ if (!accept(")")) { do { t = 0; ptag = 0; pstr[np & 15] = 0; - if (optype() >= 0) { t = ptag == 1 ? 1 : ptag == 2 ? 2 : 0; pstr[np & 15] = ptstr; } /* the type is read and dropped */ + if (optype() >= 0) { /* the type is read and dropped */ + if (ptag == 3) die("a parameter tag is .m or .d"); /* the compiler's message: .u is only a return tag */ + t = ptag == 1 ? 1 : ptag == 2 ? 2 : 0; pstr[np & 15] = ptstr; + } else if (accept(".")) { /* .m name, .d name */ if (is("m")) t = 1; else if (is("d")) t = 2; else die("a parameter tag is .m or .d"); next(); diff --git a/tests/conformance/5-declarations/fn_param_tag_u_rejected.zc b/tests/conformance/5-declarations/fn_param_tag_u_rejected.zc new file mode 100644 index 0000000..858e142 --- /dev/null +++ b/tests/conformance/5-declarations/fn_param_tag_u_rejected.zc @@ -0,0 +1,6 @@ +// expect error: a parameter tag is .m or .d +// spec: .u tags a return, never a parameter (zc0 used to accept int.u x silently) +include rt; +int f(int* .u x) { return 0; } +fn main() { return f(0); } +// zc0: error |
