File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -584,6 +584,10 @@ void ForOp::print(OpAsmPrinter &p) {
584584LogicalResult ForOp::verifyRegions () {
585585 // Check that the body defines as single block argument for the induction
586586 // variable.
587+ if (getBody ()->getNumArguments () != 1 )
588+ return emitOpError (" expected body to have a single block argument for the "
589+ " induction variable" );
590+
587591 if (getInductionVar ().getType () != getLowerBound ().getType ())
588592 return emitOpError (
589593 " expected induction variable to be same type as bounds and step" );
Original file line number Diff line number Diff line change @@ -876,3 +876,41 @@ func.func @test_do(%arg0 : !emitc.ptr<i32>) {
876876
877877 return
878878}
879+
880+ // -----
881+
882+ func.func @test_for_none_block_argument (%arg0: index ) {
883+ // expected-error@+1 {{expected body to have a single block argument for the induction variable}}
884+ " emitc.for" (%arg0 , %arg0 , %arg0 ) (
885+ {
886+ emitc.yield
887+ }
888+ ) : (index , index , index ) -> ()
889+ return
890+ }
891+
892+ // -----
893+
894+ func.func @test_for_more_than_one_block_argument (%arg0: index ) {
895+ // expected-error@+1 {{expected body to have a single block argument for the induction variable}}
896+ " emitc.for" (%arg0 , %arg0 , %arg0 ) (
897+ {
898+ ^bb0 (%i0 : index , %i1 : index ):
899+ emitc.yield
900+ }
901+ ) : (index , index , index ) -> ()
902+ return
903+ }
904+
905+ // -----
906+
907+ func.func @test_for_unmatch_type (%arg0: index ) {
908+ // expected-error@+1 {{expected induction variable to be same type as bounds}}
909+ " emitc.for" (%arg0 , %arg0 , %arg0 ) (
910+ {
911+ ^bb0 (%i0 : f32 ):
912+ emitc.yield
913+ }
914+ ) : (index , index , index ) -> ()
915+ return
916+ }
You can’t perform that action at this time.
0 commit comments