@@ -1274,6 +1274,7 @@ fn fnProtoExpr(
12741274 .is_inferred_error = false ,
12751275 .is_test = false ,
12761276 .is_extern = false ,
1277+ .is_noinline = false ,
12771278 .noalias_bits = noalias_bits ,
12781279 });
12791280
@@ -3404,7 +3405,6 @@ fn fnDecl(
34043405 };
34053406 defer fn_gz .unstack ();
34063407
3407- // TODO: support noinline
34083408 const is_pub = fn_proto .visib_token != null ;
34093409 const is_export = blk : {
34103410 const maybe_export_token = fn_proto .extern_export_inline_token orelse break :blk false ;
@@ -3418,6 +3418,10 @@ fn fnDecl(
34183418 const maybe_inline_token = fn_proto .extern_export_inline_token orelse break :blk false ;
34193419 break :blk token_tags [maybe_inline_token ] == .keyword_inline ;
34203420 };
3421+ const is_noinline = blk : {
3422+ const maybe_noinline_token = fn_proto .extern_export_inline_token orelse break :blk false ;
3423+ break :blk token_tags [maybe_noinline_token ] == .keyword_noinline ;
3424+ };
34213425
34223426 const doc_comment_index = try astgen .docCommentAsString (fn_proto .firstToken ());
34233427
@@ -3599,6 +3603,10 @@ fn fnDecl(
35993603 break :inst inst ;
36003604 };
36013605
3606+ if (has_inline_keyword and is_noinline ) {
3607+ return astgen .failTok (fn_name_token , "function prototype may not be both inline and noinline" , .{});
3608+ }
3609+
36023610 const func_inst : Zir.Inst.Ref = if (body_node == 0 ) func : {
36033611 if (! is_extern ) {
36043612 return astgen .failTok (fn_proto .ast .fn_token , "non-extern function has no body" , .{});
@@ -3625,6 +3633,7 @@ fn fnDecl(
36253633 .is_inferred_error = false ,
36263634 .is_test = false ,
36273635 .is_extern = true ,
3636+ .is_noinline = is_noinline ,
36283637 .noalias_bits = noalias_bits ,
36293638 });
36303639 } else func : {
@@ -3673,6 +3682,7 @@ fn fnDecl(
36733682 .is_inferred_error = is_inferred_error ,
36743683 .is_test = false ,
36753684 .is_extern = false ,
3685+ .is_noinline = is_noinline ,
36763686 .noalias_bits = noalias_bits ,
36773687 });
36783688 };
@@ -4108,6 +4118,7 @@ fn testDecl(
41084118 .is_inferred_error = true ,
41094119 .is_test = true ,
41104120 .is_extern = false ,
4121+ .is_noinline = false ,
41114122 .noalias_bits = 0 ,
41124123 });
41134124
@@ -10191,6 +10202,7 @@ const GenZir = struct {
1019110202 is_inferred_error : bool ,
1019210203 is_test : bool ,
1019310204 is_extern : bool ,
10205+ is_noinline : bool ,
1019410206 }) ! Zir.Inst.Ref {
1019510207 assert (args .src_node != 0 );
1019610208 const astgen = gz .astgen ;
@@ -10232,10 +10244,9 @@ const GenZir = struct {
1023210244 }
1023310245 const body_len = astgen .countBodyLenAfterFixups (body );
1023410246
10235- if (args .cc_ref != .none or args .lib_name != 0 or
10236- args .is_var_args or args .is_test or args .is_extern or
10237- args .align_ref != .none or args .section_ref != .none or
10238- args .addrspace_ref != .none or args .noalias_bits != 0 )
10247+ if (args .cc_ref != .none or args .lib_name != 0 or args .is_var_args or args .is_test or
10248+ args .is_extern or args .align_ref != .none or args .section_ref != .none or
10249+ args .addrspace_ref != .none or args .noalias_bits != 0 or args .is_noinline )
1023910250 {
1024010251 var align_body : []Zir.Inst.Index = &.{};
1024110252 var addrspace_body : []Zir.Inst.Index = &.{};
@@ -10268,6 +10279,7 @@ const GenZir = struct {
1026810279 .is_inferred_error = args .is_inferred_error ,
1026910280 .is_test = args .is_test ,
1027010281 .is_extern = args .is_extern ,
10282+ .is_noinline = args .is_noinline ,
1027110283 .has_lib_name = args .lib_name != 0 ,
1027210284 .has_any_noalias = args .noalias_bits != 0 ,
1027310285
0 commit comments