@@ -3446,20 +3446,32 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
34463446 if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) == PN_pass_stmt ) {
34473447 // no instructions
34483448 continue ;
3449- } else if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) == PN_expr_stmt ) {
3450- // an instruction; fall through
3451- } else {
3449+ } else if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) != PN_expr_stmt ) {
34523450 // not an instruction; error
3451+ not_an_instruction :
34533452 compile_syntax_error (comp , nodes [i ], "inline assembler expecting an instruction" );
34543453 return ;
34553454 }
3455+
3456+ // check structure of parse node
34563457 assert (MP_PARSE_NODE_IS_STRUCT (pns2 -> nodes [0 ]));
3457- assert (MP_PARSE_NODE_IS_NULL (pns2 -> nodes [1 ]));
3458+ if (!MP_PARSE_NODE_IS_NULL (pns2 -> nodes [1 ])) {
3459+ goto not_an_instruction ;
3460+ }
34583461 pns2 = (mp_parse_node_struct_t * )pns2 -> nodes [0 ];
3459- assert (MP_PARSE_NODE_STRUCT_KIND (pns2 ) == PN_power );
3460- assert (MP_PARSE_NODE_IS_ID (pns2 -> nodes [0 ]));
3461- assert (MP_PARSE_NODE_IS_STRUCT_KIND (pns2 -> nodes [1 ], PN_trailer_paren ));
3462+ if (MP_PARSE_NODE_STRUCT_KIND (pns2 ) != PN_power ) {
3463+ goto not_an_instruction ;
3464+ }
3465+ if (!MP_PARSE_NODE_IS_ID (pns2 -> nodes [0 ])) {
3466+ goto not_an_instruction ;
3467+ }
3468+ if (!MP_PARSE_NODE_IS_STRUCT_KIND (pns2 -> nodes [1 ], PN_trailer_paren )) {
3469+ goto not_an_instruction ;
3470+ }
34623471 assert (MP_PARSE_NODE_IS_NULL (pns2 -> nodes [2 ]));
3472+
3473+ // parse node looks like an instruction
3474+ // get instruction name and args
34633475 qstr op = MP_PARSE_NODE_LEAF_ARG (pns2 -> nodes [0 ]);
34643476 pns2 = (mp_parse_node_struct_t * )pns2 -> nodes [1 ]; // PN_trailer_paren
34653477 mp_parse_node_t * pn_arg ;
0 commit comments