harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit a43e3c76072c0d4334117a72d87ae3dfe60c54e6
parent 021e1ba876d1dfe40a7474ad2118d231714b19c6
Author: Sebastian <sebastian@sebsite.pw>
Date:   Sun, 22 May 2022 19:06:03 -0400

check: unparse function flag

Signed-off-by: Sebastian <sebastian@sebsite.pw>

Diffstat:
Msrc/check.c | 15+++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/check.c b/src/check.c @@ -3017,13 +3017,20 @@ check_function(struct context *ctx, if ((decl->func.flags & FN_INIT) || (decl->func.flags & FN_FINI) || (decl->func.flags & FN_TEST)) { - const char *flags = "@flags"; // TODO: Unparse flags + const char *flag; + if (decl->func.flags & FN_INIT) { + flag = "@init"; + } else if (decl->func.flags & FN_FINI) { + flag = "@fini"; + } else { + flag = "@test"; + }; expect(&adecl->loc, fntype->func.result == &builtin_type_void, - "%s function must return void", flags); + "%s function must return void", flag); expect(&adecl->loc, !decl->exported, - "%s function cannot be exported", flags); + "%s function cannot be exported", flag); expect(&adecl->loc, !afndecl->prototype.params, - "%s function cannot have parameters", flags); + "%s function cannot have parameters", flag); } if (fntype->func.flags & FN_NORETURN) { expect(&adecl->loc, fntype->func.result == &builtin_type_void,