Skip to content

Commit 9a51879

Browse files
authored
[Flang] Solved issue with inline compiler directive (#143699)
Issue was with pointer passing. Fixes #139297
1 parent 916e8f7 commit 9a51879

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ bool Prescanner::MustSkipToEndOfLine() const {
557557
return true; // skip over ignored columns in right margin (73:80)
558558
} else if (*at_ == '!' && !inCharLiteral_ &&
559559
(!inFixedForm_ || tabInCurrentLine_ || column_ != 6)) {
560-
return !IsCompilerDirectiveSentinel(at_);
560+
return !IsCompilerDirectiveSentinel(at_ + 1);
561561
} else {
562562
return false;
563563
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
! RUN: %flang_fc1 -fdebug-unparse %s 2>&1 | FileCheck %s
2+
3+
! Test that checks whether compiler directives can be inlined without mistaking it as comment.
4+
5+
module m
6+
contains
7+
#define MACRO(X) subroutine func1(X); real(2) :: X; !dir$ ignore_tkr(d) X; end subroutine func1;
8+
MACRO(foo)
9+
10+
!CHECK: SUBROUTINE func1 (foo)
11+
!CHECK: !DIR$ IGNORE_TKR (d) foo
12+
!CHECK: END SUBROUTINE func1
13+
14+
subroutine func2(foo)
15+
real(2) :: foo; !dir$ ignore_tkr(d) foo;
16+
end subroutine func2
17+
18+
!CHECK: SUBROUTINE func2 (foo)
19+
!CHECK: !DIR$ IGNORE_TKR (d) foo
20+
!CHECK: END SUBROUTINE func2
21+
22+
subroutine func3(foo)
23+
real(2) :: foo; !dir$ ignore_tkr(d) foo; end subroutine func3;
24+
25+
!CHECK: SUBROUTINE func3 (foo)
26+
!CHECK: !DIR$ IGNORE_TKR (d) foo
27+
!CHECK: END SUBROUTINE func3
28+
29+
end module

0 commit comments

Comments
 (0)