Index: flang/docs/Extensions.md =================================================================== --- flang/docs/Extensions.md +++ flang/docs/Extensions.md @@ -363,6 +363,7 @@ * 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 ## Preprocessing behavior Index: flang/lib/Parser/prescan.cpp =================================================================== --- flang/lib/Parser/prescan.cpp +++ flang/lib/Parser/prescan.cpp @@ -772,8 +772,36 @@ return false; } +static bool isAtProcess(const char *p) { + const std::string pAtProc{"process"}; + std::size_t i{0}; + bool notAtProcess{false}; + while (true) { + p++; + if (ToLowerCaseLetter(*p) == pAtProc[i]) { + i++; + } else { + if (*p != ' ' && *p != '\t' && *p != '\n') { + notAtProcess = true; + } + break; + } + } + if (i == pAtProc.size() && !notAtProcess) + return true; + + return false; +} + bool Prescanner::IsFixedFormCommentLine(const char *start) const { const char *p{start}; + + // The @process directive must start in column 1. + if (*p == '@') { + const char *q{p}; + if (isAtProcess(q)) + return true; + } if (IsFixedFormCommentChar(*p) || *p == '%' || // VAX %list, %eject, &c. ((*p == 'D' || *p == 'd') && !features_.IsEnabled(LanguageFeature::OldDebugLines))) { @@ -805,6 +833,12 @@ p = SkipWhiteSpaceAndCComments(p); if (*p == '!' || *p == '\n') { return p; + } else if (*p == '@') { + const char *q{p}; + if (isAtProcess(q)) + return p; + else + return nullptr; } else { return nullptr; } Index: flang/test/Parser/at-process.f =================================================================== --- /dev/null +++ flang/test/Parser/at-process.f @@ -0,0 +1,25 @@ +! 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 + 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 +@processopt(3) + +!CHECK: Character in fixed-form label field must be a digit +@processs + +!CHECK: Character in fixed-form label field must be a digit +@proce + +!CHECK: Character in fixed-form label field must be a digit +@precoss Index: flang/test/Parser/at-process.f90 =================================================================== --- /dev/null +++ flang/test/Parser/at-process.f90 @@ -0,0 +1,25 @@ +! 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 +subroutine f() +print *, "@process" + ! @process +end subroutine f + +!CHECK: error: expected '(' +@p + +!CHECK: error: expected ')' +@processopt(3) + +!CHECK: error: expected '(' +@processs + +!CHECK: error: expected '(' +@proce +end +