Skip to content

Commit ba2f40a

Browse files
authored
[flang][openacc] Allow acc routine before implicit part (#71460)
Allow position of the acc routine in the implicit part.
1 parent edfaae8 commit ba2f40a

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ struct ImplicitPartStmt {
413413
Statement<common::Indirection<OldParameterStmt>>,
414414
Statement<common::Indirection<FormatStmt>>,
415415
Statement<common::Indirection<EntryStmt>>,
416-
common::Indirection<CompilerDirective>>
416+
common::Indirection<CompilerDirective>,
417+
common::Indirection<OpenACCDeclarativeConstruct>>
417418
u;
418419
};
419420

flang/lib/Parser/Fortran-parsers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ TYPE_PARSER(first(
114114
construct<ImplicitPartStmt>(statement(indirect(oldParameterStmt))),
115115
construct<ImplicitPartStmt>(statement(indirect(formatStmt))),
116116
construct<ImplicitPartStmt>(statement(indirect(entryStmt))),
117-
construct<ImplicitPartStmt>(indirect(compilerDirective))))
117+
construct<ImplicitPartStmt>(indirect(compilerDirective)),
118+
construct<ImplicitPartStmt>(indirect(openaccDeclarativeConstruct))))
118119

119120
// R512 internal-subprogram -> function-subprogram | subroutine-subprogram
120121
// Internal subprograms are not program units, so their END statements
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
! This test checks correct lowering when OpenACC routine directive is placed
2+
! before implicit none.
3+
4+
! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
5+
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
6+
7+
module dummy_mod
8+
contains
9+
10+
subroutine sub1(i)
11+
!$acc routine seq
12+
integer :: i
13+
end subroutine
14+
end module
15+
16+
program test_acc_routine
17+
use dummy_mod
18+
19+
!$acc routine(sub2) seq
20+
21+
implicit none
22+
23+
integer :: i
24+
25+
contains
26+
subroutine sub2()
27+
end subroutine
28+
29+
end program
30+
31+
! CHECK: acc.routine @acc_routine_1 func(@_QFPsub2) seq
32+
! CHECK: acc.routine @acc_routine_0 func(@_QMdummy_modPsub1) seq
33+
! CHECK: func.func @_QMdummy_modPsub1(%arg0: !fir.ref<i32> {fir.bindc_name = "i"}) attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
34+
! CHECK: func.func @_QQmain() attributes {fir.bindc_name = "test_acc_routine"}
35+
! CHECK: func.func @_QFPsub2() attributes {acc.routine_info = #acc.routine_info<[@acc_routine_1]>}

0 commit comments

Comments
 (0)