Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ struct ImplicitPartStmt {
Statement<common::Indirection<OldParameterStmt>>,
Statement<common::Indirection<FormatStmt>>,
Statement<common::Indirection<EntryStmt>>,
common::Indirection<CompilerDirective>>
common::Indirection<CompilerDirective>,
common::Indirection<OpenACCDeclarativeConstruct>>
u;
};

Expand Down
3 changes: 2 additions & 1 deletion flang/lib/Parser/Fortran-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ TYPE_PARSER(first(
construct<ImplicitPartStmt>(statement(indirect(oldParameterStmt))),
construct<ImplicitPartStmt>(statement(indirect(formatStmt))),
construct<ImplicitPartStmt>(statement(indirect(entryStmt))),
construct<ImplicitPartStmt>(indirect(compilerDirective))))
construct<ImplicitPartStmt>(indirect(compilerDirective)),
construct<ImplicitPartStmt>(indirect(openaccDeclarativeConstruct))))

// R512 internal-subprogram -> function-subprogram | subroutine-subprogram
// Internal subprograms are not program units, so their END statements
Expand Down
34 changes: 34 additions & 0 deletions flang/test/Lower/OpenACC/acc-routine04.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
! This test checks correct lowering when OpenACC routine directive is placed
! before implicit none.

! RUN: bbc -fopenacc -emit-fir %s -o - | FileCheck %s
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s

module dummy_mod
contains

subroutine sub1(i)
!$acc routine seq
integer :: i
end subroutine
end module

program test_acc_routine
use dummy_mod

!$acc routine(sub2) seq

implicit none

integer :: i

contains
subroutine sub2()
end subroutine

end program

! CHECK: acc.routine @acc_routine_1 func(@_QFPsub2) seq
! CHECK: acc.routine @acc_routine_0 func(@_QMdummy_modPsub1) seq
! CHECK: func.func @_QMdummy_modPsub1(%arg0: !fir.ref<i32> {fir.bindc_name = "i"}) attributes {acc.routine_info = #acc.routine_info<[@acc_routine_0]>}
! CHECK: func.func @_QQmain() attributes {fir.bindc_name = "test_acc_routine"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a check that sub2 has acc_routine_1 attached?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I'll add it.