[flang-commits] [flang] 3e86eda - [flang] Allow "name: value" in compiler directives

peter klausler via flang-commits flang-commits at lists.llvm.org
Thu Oct 8 10:02:13 PDT 2020


Author: peter klausler
Date: 2020-10-08T10:01:37-07:00
New Revision: 3e86eda18c3781ab63fbe47eb48bf931a8af4a48

URL: https://github.com/llvm/llvm-project/commit/3e86eda18c3781ab63fbe47eb48bf931a8af4a48
DIFF: https://github.com/llvm/llvm-project/commit/3e86eda18c3781ab63fbe47eb48bf931a8af4a48.diff

LOG: [flang] Allow "name: value" in compiler directives

Some legacy compiler directives use colons rather than
equals signs.

Differential revision: https://reviews.llvm.org/D89017

Added: 
    

Modified: 
    flang/lib/Parser/Fortran-parsers.cpp
    flang/test/Parser/compiler-directives.f90

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/Fortran-parsers.cpp b/flang/lib/Parser/Fortran-parsers.cpp
index 19b1893065fa..4bb45fced39e 100644
--- a/flang/lib/Parser/Fortran-parsers.cpp
+++ b/flang/lib/Parser/Fortran-parsers.cpp
@@ -1172,11 +1172,11 @@ constexpr auto endDirective{space >> endOfLine};
 constexpr auto ignore_tkr{
     "DIR$ IGNORE_TKR" >> optionalList(construct<CompilerDirective::IgnoreTKR>(
                              defaulted(parenthesized(some("tkr"_ch))), name))};
-TYPE_PARSER(
-    beginDirective >> sourced(construct<CompilerDirective>(ignore_tkr) ||
-                          construct<CompilerDirective>("DIR$" >>
-                              many(construct<CompilerDirective::NameValue>(
-                                  name, maybe("=" >> digitString64))))) /
+TYPE_PARSER(beginDirective >>
+    sourced(construct<CompilerDirective>(ignore_tkr) ||
+        construct<CompilerDirective>(
+            "DIR$" >> many(construct<CompilerDirective::NameValue>(name,
+                          maybe(("="_tok || ":"_tok) >> digitString64))))) /
         endDirective)
 
 TYPE_PARSER(extension<LanguageFeature::CrayPointer>(construct<BasedPointerStmt>(

diff  --git a/flang/test/Parser/compiler-directives.f90 b/flang/test/Parser/compiler-directives.f90
index c916b16b5327..f29d6fe8fce5 100644
--- a/flang/test/Parser/compiler-directives.f90
+++ b/flang/test/Parser/compiler-directives.f90
@@ -9,4 +9,8 @@ module m
   !dir$ integer
   implicit integer(a-z)
   !dir$ integer
+  !dir$ integer=64
+  !dir$ integer = 64
+  !dir$ optimize:1
+  !dir$ optimize : 1
 end


        


More information about the flang-commits mailing list