diff options
author | Michael Forney <mforney@mforney.org> | 2021-11-25 09:42:29 -0800 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2021-11-25 09:42:41 -0800 |
commit | 06d52f69408299eff611e57b39714b37abbb06a8 (patch) | |
tree | 9f4235037f80bfd68c5fb2972653798013113ed1 | |
parent | e345d6fc4e3223e2d2655114c8829538276a0bb9 (diff) |
Add __builtin_unreachable stub
-rw-r--r-- | cc.h | 1 | ||||
-rw-r--r-- | expr.c | 4 | ||||
-rw-r--r-- | qbe.c | 2 | ||||
-rw-r--r-- | scope.c | 1 |
4 files changed, 8 insertions, 0 deletions
@@ -250,6 +250,7 @@ enum builtinkind { BUILTINNANF, BUILTINOFFSETOF, BUILTINTYPESCOMPATIBLEP, + BUILTINUNREACHABLE, BUILTINVAARG, BUILTINVACOPY, BUILTINVAEND, @@ -756,6 +756,10 @@ builtinfunc(struct scope *s, enum builtinkind kind) expect(TCOMMA, "after type name"); e = mkconstexpr(&typeint, typecompatible(t, typename(s, NULL))); break; + case BUILTINUNREACHABLE: + e = mkexpr(EXPRBUILTIN, &typevoid, NULL); + e->builtin.kind = BUILTINUNREACHABLE; + break; case BUILTINVAARG: e = mkexpr(EXPRBUILTIN, NULL, assignexpr(s)); e->builtin.kind = BUILTINVAARG; @@ -954,6 +954,8 @@ funcexpr(struct func *f, struct expr *e) case BUILTINALLOCA: l = funcexpr(f, e->base); return funcinst(f, IALLOC16, ptrclass, l, NULL); + case BUILTINUNREACHABLE: + return NULL; default: fatal("internal error: unimplemented builtin"); } @@ -22,6 +22,7 @@ scopeinit(void) {"__builtin_offsetof", {.kind = DECLBUILTIN, .builtin = BUILTINOFFSETOF}}, {"__builtin_types_compatible_p", {.kind = DECLBUILTIN, .builtin = BUILTINTYPESCOMPATIBLEP}}, + {"__builtin_unreachable", {.kind = DECLBUILTIN, .builtin = BUILTINUNREACHABLE}}, {"__builtin_va_arg", {.kind = DECLBUILTIN, .builtin = BUILTINVAARG}}, {"__builtin_va_copy", {.kind = DECLBUILTIN, .builtin = BUILTINVACOPY}}, {"__builtin_va_end", {.kind = DECLBUILTIN, .builtin = BUILTINVAEND}}, |