Add support for the following Fortran dialect options:
-std=f2018
It also adds one test cases. Currently only f2018 is allowed as the standard.
Differential D97119
[flang][driver] Add options for -std=f2018 arnamoy10 on Feb 20 2021, 7:52 AM. Authored by
Details Add support for the following Fortran dialect options: -std=f2018 It also adds one test cases. Currently only f2018 is allowed as the standard.
Diff Detail
Unit Tests Event TimelineComment Actions Hi @arnamoy10 , thank for working on this! I suggest making it more explicit that the new option is about _enabling standard conformance checks_. So e.g. enableConformanceChecks rather than setStandard (or set_EnableConformanceChecks if the member variable is called EnableConformanceChecks). I am also mindful that adding -std=f2018 might be a bit confusing to users if we don't support other versions of the language. @tskeith raised this point earlier. Perhaps we should use e..g -fstd-conf-checks/-fno-std-conf-checks instead? This could be an alias for -Mstandard in f18. We would replace it with -std=<arg> once that makes more sense.
Comment Actions
Comment Actions I agree with @tskeith that -Mstandard is not exactly orthogonal to -std, the former being about warning for non-standard extensions/deviations and the latter being about use of standard fortran, but from a different standard version. I would expect -Mstandard to apply to whatever value of -std you gave the compiler. I think the gfortran analog to -Mstandard is -fpedantic or -fpedantic-errors - see https://gcc.gnu.org/onlinedocs/gfortran/Error-and-Warning-Options.html#Error-and-Warning-Options. The docs have a little joke in them about the feature not doing what users want, but I think that's just a witty way to say that the feature is incomplete, but that it is expected to catch things in theory. So maybe -fpedantic{-errors} is a good thing to substitute for -Mstandard? FWIW, I think supporting -std with only one supported option is a reasonable thing to do and will help with folks porting codes to flang from gfortran to accept the option and to know what's supported and what is not. Perhaps the perfect thing would be supporting all the sensible gfortran values for -std, but emitting a (downgradable) warning or remark when one that is not supported is given. That would let users know what they are dealing with until the day when flang supports other values for -std. I doubt supporting older versions is on anyone's short-term roadmap, but patches would probably be welcomed on that. I guess there will one day be a -std=f202X option supported too! Comment Actions I agree with @richard.barton.arm that we could add -std= now, even if only for a subset of possible language standards. I expect that standard conformance checks would be quite pervasive, and it would be better to design the infrastructure for such checks earlier rather than try to retrofit them at a later stage when we have to start supporting f202x, etc. Comment Actions Updating the patch to make -pedantic and -f2018 behave the same way, also updated the test case accordingly.
Comment Actions
Comment Actions Adding one more update that is probably required in semanticContext (inspired by f18), also updated test case to require flang-driver
Comment Actions
Comment Actions Thank you for updating this @arnamoy10! One thing worth pointing out - this patch adds -pedantic rather than -fpendatic as @richard.barton.arm suggested. That was clearly a typo, so everything is good. IMO this is ready to land provided that:
These are small changes and I'm happy for you to apply them when merging (rather than updating here first).
|
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 2
clang
(from https://clang.llvm.org/docs/UsersManual.html):