[PATCH] D85693: [flang] Allow compiler directives in more places

Tim Keith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 11 08:38:00 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf715717aa8c: [flang] Allow compiler directives in more places (authored by tskeith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D85693/new/

https://reviews.llvm.org/D85693

Files:
  flang/include/flang/Parser/parse-tree.h
  flang/lib/Parser/Fortran-parsers.cpp
  flang/lib/Parser/program-parsers.cpp
  flang/lib/Semantics/resolve-names.cpp
  flang/test/Parser/compiler-directives.f90


Index: flang/test/Parser/compiler-directives.f90
===================================================================
--- /dev/null
+++ flang/test/Parser/compiler-directives.f90
@@ -0,0 +1,11 @@
+! RUN: %f18 -funparse %s 2>&1
+
+! Test that compiler directives can appear in various places.
+
+module m
+  !dir$ integer
+  use iso_fortran_env
+  !dir$ integer
+  implicit integer(a-z)
+  !dir$ integer
+end
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -5916,7 +5916,8 @@
   Walk(std::get<2>(x.t));
   Walk(std::get<3>(x.t));
   Walk(std::get<4>(x.t));
-  const std::list<parser::DeclarationConstruct> &decls{std::get<5>(x.t)};
+  Walk(std::get<5>(x.t));
+  const std::list<parser::DeclarationConstruct> &decls{std::get<6>(x.t)};
   for (const auto &decl : decls) {
     if (const auto *spec{
             std::get_if<parser::SpecificationConstruct>(&decl.u)}) {
Index: flang/lib/Parser/program-parsers.cpp
===================================================================
--- flang/lib/Parser/program-parsers.cpp
+++ flang/lib/Parser/program-parsers.cpp
@@ -61,7 +61,7 @@
 //         [declaration-construct]...
 TYPE_CONTEXT_PARSER("specification part"_en_US,
     construct<SpecificationPart>(many(openaccDeclarativeConstruct),
-        many(openmpDeclarativeConstruct),
+        many(openmpDeclarativeConstruct), many(indirect(compilerDirective)),
         many(statement(indirect(Parser<UseStmt>{}))),
         many(unambiguousStatement(indirect(Parser<ImportStmt>{}))),
         implicitPart, many(declarationConstruct)))
@@ -128,7 +128,7 @@
 // statement.
 constexpr auto limitedSpecificationPart{inContext("specification part"_en_US,
     construct<SpecificationPart>(many(openaccDeclarativeConstruct),
-        many(openmpDeclarativeConstruct),
+        many(openmpDeclarativeConstruct), many(indirect(compilerDirective)),
         many(statement(indirect(Parser<UseStmt>{}))),
         many(unambiguousStatement(indirect(Parser<ImportStmt>{}))),
         implicitPart, many(limitedDeclarationConstruct)))};
Index: flang/lib/Parser/Fortran-parsers.cpp
===================================================================
--- flang/lib/Parser/Fortran-parsers.cpp
+++ flang/lib/Parser/Fortran-parsers.cpp
@@ -116,7 +116,8 @@
     construct<ImplicitPartStmt>(statement(indirect(parameterStmt))),
     construct<ImplicitPartStmt>(statement(indirect(oldParameterStmt))),
     construct<ImplicitPartStmt>(statement(indirect(formatStmt))),
-    construct<ImplicitPartStmt>(statement(indirect(entryStmt)))))
+    construct<ImplicitPartStmt>(statement(indirect(entryStmt))),
+    construct<ImplicitPartStmt>(indirect(compilerDirective))))
 
 // R512 internal-subprogram -> function-subprogram | subroutine-subprogram
 // Internal subprograms are not program units, so their END statements
Index: flang/include/flang/Parser/parse-tree.h
===================================================================
--- flang/include/flang/Parser/parse-tree.h
+++ flang/include/flang/Parser/parse-tree.h
@@ -403,7 +403,8 @@
       Statement<common::Indirection<ParameterStmt>>,
       Statement<common::Indirection<OldParameterStmt>>,
       Statement<common::Indirection<FormatStmt>>,
-      Statement<common::Indirection<EntryStmt>>>
+      Statement<common::Indirection<EntryStmt>>,
+      common::Indirection<CompilerDirective>>
       u;
 };
 
@@ -430,6 +431,7 @@
   TUPLE_CLASS_BOILERPLATE(SpecificationPart);
   std::tuple<std::list<OpenACCDeclarativeConstruct>,
       std::list<OpenMPDeclarativeConstruct>,
+      std::list<common::Indirection<CompilerDirective>>,
       std::list<Statement<common::Indirection<UseStmt>>>,
       std::list<Statement<common::Indirection<ImportStmt>>>, ImplicitPart,
       std::list<DeclarationConstruct>>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85693.284759.patch
Type: text/x-patch
Size: 3890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200811/1501828d/attachment.bin>


More information about the llvm-commits mailing list