Skip to content

Commit aeb12e9

Browse files
committed
Solved an issue with preprocessor comment handling
Issue was with pointer passing
1 parent b49c789 commit aeb12e9

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

flang/lib/Parser/prescan.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ bool Prescanner::MustSkipToEndOfLine() const {
564564
return true; // skip over ignored columns in right margin (73:80)
565565
} else if (*at_ == '!' && !inCharLiteral_ &&
566566
(!inFixedForm_ || tabInCurrentLine_ || column_ != 6)) {
567-
return !IsCompilerDirectiveSentinel(at_);
567+
return !IsCompilerDirectiveSentinel(at_ + 1);
568568
} else {
569569
return false;
570570
}

flang/test/temp_test/m.mod

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
!mod$ v1 sum:17d756d2fb56521c
2+
module m
3+
contains
4+
subroutine func1(foo)
5+
real(2)::foo
6+
!dir$ ignore_tkr(d) foo
7+
end
8+
subroutine func3(foo)
9+
real(2)::foo
10+
!dir$ ignore_tkr(d) foo
11+
end
12+
subroutine func4(foo)
13+
real(2)::foo
14+
!dir$ ignore_tkr(d) foo
15+
end
16+
end

flang/test/temp_test/test.f90

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module m
2+
contains
3+
4+
! Directive inside macro on same line; works
5+
#define MACRO(X) subroutine func1(X); real(2) :: X; !dir$ ignore_tkr(d) X; end subroutine func1;
6+
MACRO(foo)
7+
8+
! Same subroutine, but after preprocessor expansion (-e -fno-reformat); syntax error
9+
! subroutine func2(foo); real(2) :: foo; !dir$ ignore_tkr(d) foo; end subroutine func2;
10+
11+
! Parses with line wrap before !dir$
12+
subroutine func3(foo); real(2) :: foo;
13+
!dir$ ignore_tkr(d) foo; end subroutine func3;
14+
15+
! Parses with line wrap after !dir$, but swallows the directive
16+
subroutine func4(foo); real(2) :: foo; !dir$ ignore_tkr(d) foo;
17+
end subroutine func4;
18+
19+
end module

0 commit comments

Comments
 (0)