[PATCH] D97119: [flang][driver] Add options for -std=f2018

Andrzej Warzynski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 15 04:55:03 PDT 2021


awarzynski added inline comments.


================
Comment at: clang/include/clang/Driver/Options.td:3535-3536
   MarshallingInfoFlag<DiagnosticOpts<"PedanticErrors">>;
-def pedantic : Flag<["-", "--"], "pedantic">, Group<pedantic_Group>, Flags<[CC1Option]>,
-  MarshallingInfoFlag<DiagnosticOpts<"Pedantic">>;
+def pedantic : Flag<["-", "--"], "pedantic">, Group<pedantic_Group>, Flags<[CC1Option,FlangOption,FC1Option]>,
+  HelpText<"Issue warnings for uses of extensions to Fortran">, MarshallingInfoFlag<DiagnosticOpts<"Pedantic">>;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, Flags<[CC1Option]>,
----------------
As this options is shared with Clang, the description should be generic enough so that it works for both `clang` and `flang`. Some sources for inspiration below:

**gfortran 1**
```
 gfortran --help=common | grep "\-\-pedantic"
  --pedantic                  Same as -Wpedantic.  Use the latter option instead.
  --pedantic-errors       Same as -pedantic-errors.  Use the latter option instead.
```
**gfortran 2**
```
$ gfortran --help=common | grep "\-Wpedantic "
  -Wpedantic                  Issue warnings needed for strict compliance to the standard.
```
**clang** 
(from https://clang.llvm.org/docs/UsersManual.html):
```
-pedantic
Warn on language extensions.

-pedantic-errors
Error on language extensions.
```


================
Comment at: clang/lib/Driver/ToolChains/Flang.cpp:43
+                            options::OPT_flarge_sizes,
+                            options::OPT_pedantic,
+                            options::OPT_std_EQ});
----------------
`-pedantic` controls errors and warning messages. It's not really a dialect option.


================
Comment at: flang/lib/Frontend/CompilerInvocation.cpp:371-374
+  if (args.hasArg(clang::driver::options::OPT_fopenmp)) {
+    res.frontendOpts().features_.Enable(
+        Fortran::common::LanguageFeature::OpenMP);
+  }
----------------
DELETEME?


================
Comment at: flang/test/Driver/std2018.f90:6-11
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang-new -fsyntax-only -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang-new -fsyntax-only -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %f18 -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %f18 -fsyntax-only -Mstandard %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: not %flang-new -fsyntax-only -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
----------------
We are moving towards sharing all of the tests between the new and the old drivers (more context: https://reviews.llvm.org/D98257). We should avoid:
* `%f18`, which is meant for `f18` only,
* `%flang-new`, which is meant for `flang-new` only.

So this whole section is a bit problematic. As these options don't require any particular logic in the compiler driver (i.e. `flang-new`), I suggest deleting it. It is sufficient to test with the frontend driver `%flang_fc1` (i.e. `flang-new -fc1`).


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

https://reviews.llvm.org/D97119



More information about the cfe-commits mailing list