Skip to content

Commit 2dc0fa1

Browse files
authored
[Flang] Nested directives are comments (#166348)
Directives cannot be nested. A directive sentinel that appears within another directive should be ignored, and instead fall back to be treated as a line comment. Fixes: #165874
1 parent cc3ad20 commit 2dc0fa1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-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_ + 1);
560+
return InCompilerDirective() || !IsCompilerDirectiveSentinel(at_ + 1);
561561
} else {
562562
return false;
563563
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s 2>&1 | FileCheck %s --match-full-lines
2+
3+
subroutine func
4+
implicit none
5+
! CHECK: !$OMP NOTHING
6+
!$omp nothing !$omp Cannot nest directives inside directives; must be interpreted as a comment
7+
end subroutine func

0 commit comments

Comments
 (0)