diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2021-05-20 14:51:11 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-05-20 14:54:44 +0200 |
| commit | 569525f03e17ba32204733108a950a5170662299 (patch) | |
| tree | 7a6d4daf267525bc0ca2b8fc8796c989750889d7 /src/stage1/analyze.cpp | |
| parent | 9910bfa6d887cd28dba3ac99ac0f0acf8d6e5056 (diff) | |
| download | zig-569525f03e17ba32204733108a950a5170662299.tar.gz zig-569525f03e17ba32204733108a950a5170662299.zip | |
stage1: support inline keyword on function decls
This is an alternative to callconv(.Inline). Using an inline keyword
as well as an explicit callconv() is a compile error.
Diffstat (limited to 'src/stage1/analyze.cpp')
| -rw-r--r-- | src/stage1/analyze.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index a87fd80613..581e34acfc 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -1638,6 +1638,9 @@ CallingConvention cc_from_fn_proto(AstNodeFnProto *fn_proto) { if (fn_proto->is_extern || fn_proto->is_export) return CallingConventionC; + if (fn_proto->fn_inline == FnInlineAlways) + return CallingConventionInline; + return CallingConventionUnspecified; } @@ -3649,7 +3652,7 @@ ZigFn *create_fn(CodeGen *g, AstNode *proto_node) { assert(proto_node->type == NodeTypeFnProto); AstNodeFnProto *fn_proto = &proto_node->data.fn_proto; - ZigFn *fn_entry = create_fn_raw(g, fn_proto->is_noinline); + ZigFn *fn_entry = create_fn_raw(g, fn_proto->fn_inline == FnInlineNever); fn_entry->proto_node = proto_node; fn_entry->body_node = (proto_node->data.fn_proto.fn_def_node == nullptr) ? nullptr : @@ -3742,6 +3745,9 @@ static void resolve_decl_fn(CodeGen *g, TldFn *tld_fn) { CallingConvention cc; if (fn_proto->callconv_expr != nullptr) { + if (fn_proto->fn_inline == FnInlineAlways) { + add_node_error(g, fn_proto->callconv_expr, buf_sprintf("explicit callconv incompatible with inline keyword")); + } ZigType *cc_enum_value = get_builtin_type(g, "CallingConvention"); ZigValue *result_val = analyze_const_value(g, child_scope, fn_proto->callconv_expr, |
