Skip to content

Commit 6048c2f

Browse files
authored
[flang][openacc] Suppport !@acc compiler sentinel (#161706)
1 parent 11faf88 commit 6048c2f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

flang/lib/Parser/parsing.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const SourceFile *Parsing::Prescan(const std::string &path, Options options) {
8585
if (options.features.IsEnabled(LanguageFeature::OpenACC) ||
8686
(options.prescanAndReformat && noneOfTheAbove)) {
8787
prescanner.AddCompilerDirectiveSentinel("$acc");
88+
prescanner.AddCompilerDirectiveSentinel("@acc");
8889
}
8990
if (options.features.IsEnabled(LanguageFeature::OpenMP) ||
9091
(options.prescanAndReformat && noneOfTheAbove)) {

flang/lib/Parser/prescan.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ void Prescanner::Statement() {
147147
directiveSentinel_[4] == '\0') {
148148
// CUDA conditional compilation line.
149149
condOffset = 5;
150+
} else if (directiveSentinel_[0] == '@' && directiveSentinel_[1] == 'a' &&
151+
directiveSentinel_[2] == 'c' && directiveSentinel_[3] == 'c' &&
152+
directiveSentinel_[4] == '\0') {
153+
// OpenACC conditional compilation line.
154+
condOffset = 5;
150155
}
151156
if (condOffset && !preprocessingOnly_) {
152157
at_ += *condOffset, column_ += *condOffset;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenacc
2+
3+
subroutine test_sentinel()
4+
! Test for error since we currently do not have an OpenACC module upstream.
5+
!ERROR: Cannot parse module file for module 'openacc': Source file 'openacc.mod' was not found
6+
!@acc use openacc
7+
integer :: i
8+
9+
!$acc parallel loop
10+
do i = 1, 10
11+
end do
12+
!$acc end parallel
13+
14+
end subroutine

0 commit comments

Comments
 (0)