[flang-commits] [flang] [flang][openacc] Ignore bare acc routine in module subprogram part instead of erroring out (PR #205450)

Eugene Epshteyn via flang-commits flang-commits at lists.llvm.org
Wed Jun 24 04:34:23 PDT 2026


================
@@ -88,6 +88,26 @@ static constexpr auto globalOpenACCCompilerDirective{
     construct<ProgramUnit>(indirect(skipStuffBeforeStatement >>
         "!$ACC "_sptok >> Parser<OpenACCRoutineConstruct>{} / endOfLine))};
 
+struct WarnUnnamedOpenACCRoutineDirective {
+  using resultType = Success;
+  std::optional<Success> Parse(ParseState &state) const {
----------------
eugeneepshteyn wrote:

Turns out we already handle this error in module specification part: `ROUTINE directive without name must appear within the specification part of a subroutine or function definition, or within an interface body for a subroutine or function in an interface block`

Why don't we piggy back on that, so that we don't introduce different ways to handle the same thing?

The check is done in `AccStructureChecker::Enter()` and in order to get there we need to make the unnamed ROUTINE construct legal to be parsed in the module subprogram part.

Also note that the check in module specification part is an error, not a warning. I think we should be consistent and make both of them either an error or a warning.

If it's a warning, will probably need to change ` std::optional<ProgramTree> ProgramTree::Build(const parser::OpenACCRoutineConstruct &, SemanticsContext &)` not to DIE but to return `std::nullopt` to indicate there's no tree construct for this.



https://github.com/llvm/llvm-project/pull/205450


More information about the flang-commits mailing list