File tree Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Expand file tree Collapse file tree 4 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -1642,6 +1642,17 @@ Prescanner::IsFixedFormCompilerDirectiveLine(const char *start) const {
16421642 // This is a Continuation line, not an initial directive line.
16431643 return std::nullopt ;
16441644 }
1645+ ++column, ++p;
1646+ }
1647+ if (isOpenMPConditional) {
1648+ for (; column <= fixedFormColumnLimit_; ++column, ++p) {
1649+ if (IsSpaceOrTab (p)) {
1650+ } else if (*p == ' !' ) {
1651+ return std::nullopt ; // !$ ! is a comment, not a directive
1652+ } else {
1653+ break ;
1654+ }
1655+ }
16451656 }
16461657 if (const char *ss{IsCompilerDirectiveSentinel (
16471658 sentinel, static_cast <std::size_t >(sp - sentinel))}) {
@@ -1657,8 +1668,17 @@ Prescanner::IsFreeFormCompilerDirectiveLine(const char *start) const {
16571668 p && *p++ == ' !' ) {
16581669 if (auto maybePair{IsCompilerDirectiveSentinel (p)}) {
16591670 auto offset{static_cast <std::size_t >(p - start - 1 )};
1660- return {LineClassification{LineClassification::Kind::CompilerDirective,
1661- offset, maybePair->first }};
1671+ const char *sentinel{maybePair->first };
1672+ if ((sentinel[0 ] == ' $' && sentinel[1 ] == ' \0 ' ) || sentinel[1 ] == ' @' ) {
1673+ if (const char *comment{IsFreeFormComment (maybePair->second )}) {
1674+ if (*comment == ' !' ) {
1675+ // Conditional line comment - treat as comment
1676+ return std::nullopt ;
1677+ }
1678+ }
1679+ }
1680+ return {LineClassification{
1681+ LineClassification::Kind::CompilerDirective, offset, sentinel}};
16621682 }
16631683 }
16641684 return std::nullopt ;
Original file line number Diff line number Diff line change 1818* $1 continue
1919 end
2020
21- !PREPRO:!$ &
2221!PREPRO: continue
2322!PREPRO: k= 0
2423!PREPRO: k= 0
Original file line number Diff line number Diff line change 1+ !RUN: %flang_fc1 - fopenmp - fdebug- unparse %s 2 >&1 | FileCheck %s
2+ !CHECK: END
3+ !CHECK- NOT: error:
4+ end
5+ c $ !
Original file line number Diff line number Diff line change 1+ ! RUN: %flang_fc1 -fopenmp -fdebug-unparse %s 2>&1 | FileCheck %s
2+ ! CHECK: END
3+ ! CHECK-NOT: error:
4+ end
5+ ! $ !
You can’t perform that action at this time.
0 commit comments