[flang-commits] [flang] [flang] Implement !DIR$ VECTOR ALWAYS (PR #93830)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Fri May 31 04:56:17 PDT 2024


================
@@ -2508,8 +2531,30 @@ class FirConverter : public Fortran::lower::AbstractConverter {
     }
   }
 
-  void genFIR(const Fortran::parser::CompilerDirective &) {
-    // TODO
+  void attachLoopDirective(const Fortran::parser::CompilerDirective &dir,
+                           Fortran::lower::pft::Evaluation *e) {
+    while (e->isDirective()) {
+      e = e->lexicalSuccessor;
+    }
+
+    if (e->isA<Fortran::parser::NonLabelDoStmt>()) {
+      e->dirs.push_back(&dir);
+    } else {
+      fir::emitFatalError(toLocation(),
+                          "loop directive must appear before a loop");
----------------
tblah wrote:

I think this needs to be caught in semantics. Outputting here won't have the same format as other errors/warnings and won't be able to control them with the same machinery. Do other compilers produce warnings or errors when this directive is misplaced? It is not clear to me which would be correct.

Keep the fatal error here to catch bugs in semantics.

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


More information about the flang-commits mailing list