Skip to content

Commit 1a04a5f

Browse files
clementvaltstellar
authored andcommitted
[flang] Fix optional assertion in PFTBuilder
D142279 enabled assertion in libstdc++ and one was triggered in the PFTBuilder because an optional was access even if it was null. This patch fix this issue and add a regression test. Reviewed By: jeanPerier Differential Revision: https://reviews.llvm.org/D143589 (cherry picked from commit 3f55311)
1 parent bef3459 commit 1a04a5f

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

flang/lib/Lower/PFTBuilder.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ class PFTBuilder {
508508
auto branchTargetMatch = [&]() {
509509
if (const parser::Label targetLabel =
510510
ifCandidateStack.back().ifTargetLabel)
511-
if (targetLabel == *targetEval.label)
511+
if (targetEval.label && targetLabel == *targetEval.label)
512512
return true; // goto target match
513513
if (targetEvalIsEndDoStmt && ifCandidateStack.back().isCycleStmt)
514514
return true; // cycle target match

flang/test/Lower/pre-fir-tree08.f

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: %flang_fc1 -fdebug-pre-fir-tree -fopenacc %s | FileCheck %s
2+
program rewrite_goto
3+
integer b
4+
5+
b = dummy(10)
6+
7+
end
8+
function dummy(a)
9+
integer, a
10+
11+
do 10 i=1,10
12+
10 if(i .EQ. 1) GOTO 11
13+
i=0
14+
11 dummy = a + i
15+
return
16+
end
17+
18+
! CHECK: <<IfConstruct!>> -> 5
19+
! CHECK: 2 ^IfStmt -> 5: 10if(i.eq.1)goto11
20+
! CHECK: 3 ^GotoStmt! -> 7: goto11
21+

0 commit comments

Comments
 (0)