Index: flang/lib/Lower/PFTBuilder.cpp =================================================================== --- flang/lib/Lower/PFTBuilder.cpp +++ flang/lib/Lower/PFTBuilder.cpp @@ -503,7 +503,7 @@ for (auto it = evaluationList.begin(), end = evaluationList.end(); it != end; ++it) { auto &eval = *it; - if (eval.isA()) { + if (eval.isA() || eval.isIntermediateConstructStmt()) { ifCandidateStack.clear(); continue; } Index: flang/test/Lower/select-case-statement.f90 =================================================================== --- flang/test/Lower/select-case-statement.f90 +++ flang/test/Lower/select-case-statement.f90 @@ -252,7 +252,6 @@ print*, n end subroutine - ! CHECK-LABEL: func @_QPscharacter2 subroutine scharacter2(s) ! CHECK-DAG: %[[V_0:[0-9]+]] = fir.alloca !fir.box>> @@ -337,6 +336,47 @@ ! CHECK: return end subroutine + ! CHECK-LABEL: func @_QPsgoto + ! select case with goto exit + subroutine sgoto + n = 0 + do i=1,8 + ! CHECK: %[[i:[0-9]+]] = fir.alloca {{.*}} "_QFsgotoEi" + ! CHECK: ^bb2: // pred: ^bb1 + ! CHECK: %[[selector:[0-9]+]] = fir.load %[[i]] : !fir.ref + ! CHECK: fir.select_case %[[selector]] : i32 [#fir.upper, %c2{{.*}}, ^bb3, #fir.lower, %c5{{.*}}, ^bb4, unit, ^bb7] + ! CHECK: ^bb3: // pred: ^bb2 + ! CHECK: arith.muli %c10{{[^0]}} + ! CHECK: br ^bb9 + ! CHECK: ^bb4: // pred: ^bb2 + ! CHECK: arith.muli %c1000{{[^0]}} + ! CHECK: cond_br {{.*}}, ^bb5, ^bb6 + ! CHECK: ^bb5: // pred: ^bb4 + ! CHECK: br ^bb8 + ! CHECK: ^bb6: // pred: ^bb4 + ! CHECK: arith.muli %c10000{{[^0]}} + ! CHECK: br ^bb9 + ! CHECK: ^bb7: // pred: ^bb2 + ! CHECK: arith.muli %c100{{[^0]}} + ! CHECK: br ^bb8 + ! CHECK: ^bb8: // 2 preds: ^bb5, ^bb7 + ! CHECK: br ^bb9 + ! CHECK: ^bb9: // 3 preds: ^bb3, ^bb6, ^bb8 + ! CHECK: fir.call @_FortranAioBeginExternalListOutput + select case(i) + case (:2) + n = i * 10 + case (5:) + n = i * 1000 + if (i <= 6) goto 9 + n = i * 10000 + case default + n = i * 100 + 9 end select + print*, n + enddo + ! CHECK: return + end ! CHECK-LABEL: func @_QPswhere subroutine swhere(num) @@ -453,6 +493,9 @@ call sempty(3) ! expected output: 3 i:case default; 3 c:case default print* + call sgoto ! expected output: 10 20 300 400 5000 6000 70000 80000 + + print* call swhere(1) ! expected output: 42. call sforall(1) ! expected output: 42. end