diff --git a/flang/docs/Extensions.md b/flang/docs/Extensions.md index a91596765a594..a422b2c7eb0a4 100644 --- a/flang/docs/Extensions.md +++ b/flang/docs/Extensions.md @@ -363,6 +363,7 @@ end * Constraint C1406, which prohibits the same module name from being used in a scope for both an intrinsic and a non-intrinsic module, is implemented as a portability warning only, not a hard error. +* IBM @PROCESS directive is accepted but ignored. ## Preprocessing behavior diff --git a/flang/lib/Parser/prescan.cpp b/flang/lib/Parser/prescan.cpp index 27b5597db4259..2bbf1d67eb626 100644 --- a/flang/lib/Parser/prescan.cpp +++ b/flang/lib/Parser/prescan.cpp @@ -777,8 +777,23 @@ bool Prescanner::PadOutCharacterLiteral(TokenSequence &tokens) { return false; } +static bool IsAtProcess(const char *p) { + static const char pAtProc[]{"process"}; + for (std::size_t i{0}; i < sizeof pAtProc - 1; ++i) { + if (ToLowerCaseLetter(*++p) != pAtProc[i]) + return false; + } + return true; +} + bool Prescanner::IsFixedFormCommentLine(const char *start) const { const char *p{start}; + + // The @process directive must start in column 1. + if (*p == '@' && IsAtProcess(p)) { + return true; + } + if (IsFixedFormCommentChar(*p) || *p == '%' || // VAX %list, %eject, &c. ((*p == 'D' || *p == 'd') && !features_.IsEnabled(LanguageFeature::OldDebugLines))) { @@ -810,6 +825,8 @@ const char *Prescanner::IsFreeFormComment(const char *p) const { p = SkipWhiteSpaceAndCComments(p); if (*p == '!' || *p == '\n') { return p; + } else if (*p == '@') { + return IsAtProcess(p) ? p : nullptr; } else { return nullptr; } diff --git a/flang/test/Parser/at-process.f b/flang/test/Parser/at-process.f new file mode 100644 index 0000000000000..41b95044bfdc5 --- /dev/null +++ b/flang/test/Parser/at-process.f @@ -0,0 +1,20 @@ +! RUN: %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s + +! Test ignoring @PROCESS directive in fixed source form + +@process opt(3) +@process opt(0) +@process +@processopt(3) + subroutine f() +c@process + end + +!CHECK: Character in fixed-form label field must be a digit +@ + +!CHECK: Character in fixed-form label field must be a digit +@proce + +!CHECK: Character in fixed-form label field must be a digit +@precoss diff --git a/flang/test/Parser/at-process.f90 b/flang/test/Parser/at-process.f90 new file mode 100644 index 0000000000000..cd5b2acf3f3e0 --- /dev/null +++ b/flang/test/Parser/at-process.f90 @@ -0,0 +1,23 @@ +! RUN: not %flang_fc1 -fsyntax-only %s 2>&1 | FileCheck %s + +! Test ignoring @PROCESS directive in free source form + +@process opt(3) +@process opt(0) + @process strict +@processopt(3) +subroutine f() +print *, "@process" + ! @process +end subroutine f + +!CHECK: error: expected '(' +@p + +!CHECK: error: expected '(' +@proce + +!CHECK: error: expected '(' +@precoss +end +