Skip to content

Commit 30bf008

Browse files
committed
[flang][test] Revert some of comments; Add tests with multiple returns
1 parent 172149c commit 30bf008

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

flang/include/flang/Lower/StatementContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ class StatementContext {
7979
}
8080
}
8181

82-
/// Make a cleanup call. Retain the stack top list for a repeat call.
82+
/// Make cleanup calls. Retain the stack top list for a repeat call.
8383
void finalizeAndKeep() {
8484
assert(!cufs.empty() && "invalid finalize statement context");
8585
if (cufs.back())
8686
(*cufs.back())();
8787
}
8888

89-
/// Make a cleanup call. Clear the stack top list.
89+
/// Make cleanup calls. Clear the stack top list.
9090
void finalizeAndReset() {
9191
finalizeAndKeep();
9292
cufs.back().reset();
@@ -95,7 +95,7 @@ class StatementContext {
9595
/// Pop the stack top list.
9696
void pop() { cufs.pop_back(); }
9797

98-
/// Make a cleanup call. Pop the stack top list.
98+
/// Make cleanup calls. Pop the stack top list.
9999
void finalizeAndPop() {
100100
finalizeAndKeep();
101101
pop();
File renamed without changes.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
3+
! Check if finalization works with multiple return statements
4+
5+
program test
6+
integer, device :: a(10)
7+
logical :: l
8+
9+
if (l) then
10+
return
11+
end if
12+
13+
return
14+
end
15+
16+
! CHECK: func.func @_QQmain() attributes {fir.bindc_name = "test"} {
17+
! CHECK: %[[DECL:.*]]:2 = hlfir.declare
18+
! CHECK: cf.cond_br %{{.*}}, ^bb1, ^bb2
19+
! CHECK-NEXT: ^bb1:
20+
! CHECK-NEXT: cuf.free %[[DECL]]#1 : !fir.ref<!fir.array<10xi32>>
21+
! CHECK-NEXT: return
22+
! CHECK-NEXT: ^bb2:
23+
! CHECK-NEXT: cuf.free %[[DECL]]#1 : !fir.ref<!fir.array<10xi32>>
24+
! CHECK-NEXT: return
25+
! CHECK-NEXT: }
26+
27+
subroutine sub(l)
28+
integer, device :: a(10)
29+
logical :: l
30+
31+
if (l) then
32+
l = .false.
33+
return
34+
end if
35+
36+
return
37+
end
38+
39+
! CHECK: func.func @_QPsub(%arg0: !fir.ref<!fir.logical<4>> {fir.bindc_name = "l"}) {
40+
! CHECK: %[[DECL:.*]]:2 = hlfir.declare
41+
! CHECK: cf.cond_br %6, ^bb1, ^bb2
42+
! CHECK: ^bb1:
43+
! CHECK: cf.br ^bb3
44+
! CHECK: ^bb2:
45+
! CHECK: cf.br ^bb3
46+
! CHECK: ^bb3:
47+
! CHECK: cuf.free %[[DECL]]#1 : !fir.ref<!fir.array<10xi32>>
48+
! CHECK: }

0 commit comments

Comments
 (0)