[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
github-actions[bot] wrote: @eugeneepshteyn Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail [here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr). If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of [LLVM development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy). You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/eugeneepshteyn closed https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/jeanPerier approved this pull request. Looks good https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/tarunprabhu approved this pull request. LGTM. Thanks. https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
@@ -54,7 +54,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines, PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy, UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr, SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank, -IgnoreIrrelevantAttributes, Unsigned) +IgnoreIrrelevantAttributes, Unsigned, ImplicitNoneExternal) klausler wrote: I'd put this new name right after `ImplicitNoneTypeAlways` instead of at the end of the list. https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
@@ -34,13 +34,13 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines, EquivalenceSameNonSequence, AdditionalIntrinsics, AnonymousParents, OldLabelDoEndStatements, LogicalIntegerAssignment, EmptySourceFile, ProgramReturn, ImplicitNoneTypeNever, ImplicitNoneTypeAlways, -ForwardRefImplicitNone, OpenAccessAppend, BOZAsDefaultInteger, -DistinguishableSpecifics, DefaultSave, PointerInSeqType, NonCharacterFormat, -SaveMainProgram, SaveBigMainProgramVariables, -DistinctArrayConstructorLengths, PPCVector, RelaxedIntentInChecking, -ForwardRefImplicitNoneData, NullActualForAllocatable, -ActualIntegerConvertedToSmallerKind, HollerithOrCharacterAsBOZ, -BindingAsProcedure, StatementFunctionExtensions, +ImplicitNoneExternal, ForwardRefImplicitNone, OpenAccessAppend, eugeneepshteyn wrote: As requested, I moved `ImplicitNoneExternal` to after `ImplicitNoneTypeAlways`. The other changes below are due to `clang-format`. https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/eugeneepshteyn updated
https://github.com/llvm/llvm-project/pull/125248
>From 11cb96c5dcb911a24596c646fbbc3cc6f3fd10a4 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn
Date: Fri, 31 Jan 2025 10:52:00 -0500
Subject: [PATCH 1/5] [flang] Add support for -fimplicit-none-ext option
When enabled, flang behaves as if "implicit none(external)" was specified for
all relevant constructs in Fortran source file.
Signed-off-by: Eugene Epshteyn
---
clang/include/clang/Driver/Options.td | 1 +
clang/lib/Driver/ToolChains/Flang.cpp | 1 +
flang/include/flang/Common/Fortran-features.h | 2 +-
flang/lib/Common/Fortran-features.cpp | 1 +
flang/lib/Frontend/CompilerInvocation.cpp | 7 +++
flang/lib/Semantics/resolve-names.cpp | 2 +-
6 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/Driver/Options.td
b/clang/include/clang/Driver/Options.td
index d8123cc39fdc95..c33fdb6a1c163d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6876,6 +6876,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that
backslash in string in
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym
of .NEQV.">;
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable
logical abbreviations">;
defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing
allowed unless overridden by IMPLICIT statements">;
+defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit
externals allowed">;
defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing
underscore to external names">;
defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f",
"ppc-native-vector-element-order",
PosFlag,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp
b/clang/lib/Driver/ToolChains/Flang.cpp
index 1ae865f379110b..e4019c43496874 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,6 +42,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
options::OPT_fopenacc,
options::OPT_finput_charset_EQ,
options::OPT_fimplicit_none,
+options::OPT_fimplicit_none_ext,
options::OPT_fno_implicit_none,
options::OPT_fbackslash,
options::OPT_fno_backslash,
diff --git a/flang/include/flang/Common/Fortran-features.h
b/flang/include/flang/Common/Fortran-features.h
index 9549e8bfbbef0b..23c7afe9eec2bb 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Common/Fortran-features.h
@@ -54,7 +54,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy,
UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr,
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank,
-IgnoreIrrelevantAttributes, Unsigned)
+IgnoreIrrelevantAttributes, Unsigned, ImplicitNoneExternal)
// Portability and suspicious usage warnings
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
diff --git a/flang/lib/Common/Fortran-features.cpp
b/flang/lib/Common/Fortran-features.cpp
index 3565275915a312..678e2274960ac4 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Common/Fortran-features.cpp
@@ -22,6 +22,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
disable_.set(LanguageFeature::CudaUnified);
disable_.set(LanguageFeature::ImplicitNoneTypeNever);
disable_.set(LanguageFeature::ImplicitNoneTypeAlways);
+ disable_.set(LanguageFeature::ImplicitNoneExternal);
disable_.set(LanguageFeature::DefaultSave);
disable_.set(LanguageFeature::SaveMainProgram);
// These features, if enabled, conflict with valid standard usage,
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp
b/flang/lib/Frontend/CompilerInvocation.cpp
index 68b5950d3a51b7..e9ef308e987941 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -740,6 +740,13 @@ static bool parseFrontendArgs(FrontendOptions &opts,
llvm::opt::ArgList &args,
args.hasFlag(clang::driver::options::OPT_fimplicit_none,
clang::driver::options::OPT_fno_implicit_none, false));
+ // -f{no-}implicit-none-ext
+ opts.features.Enable(
+ Fortran::common::LanguageFeature::ImplicitNoneExternal,
+ args.hasFlag(clang::driver::options::OPT_fimplicit_none_ext,
+ clang::driver::options::OPT_fno_implicit_none_ext, false));
+
+
// -f{no-}backslash
opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
args.hasFlag(clang::driver::options::OPT_fbackslash,
diff --git a/flang/lib/Semantics/resolve-names.cpp
b/flang/lib/Semantics/resolve-names.
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/klausler approved this pull request. Well done! Thank you. https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/klausler edited https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
llvmbot wrote:
@llvm/pr-subscribers-flang-semantics
Author: Eugene Epshteyn (eugeneepshteyn)
Changes
When -fimplicit-none-ext is passed, flang behaves as if "implicit
none(external)" was specified for all relevant constructs in Fortran source
file.
Note: implicit17.f90 was based on implicit07.f90 with `implicit none(external)`
removed and `-fimplicit-none-ext` added.
---
Full diff: https://github.com/llvm/llvm-project/pull/125248.diff
7 Files Affected:
- (modified) clang/include/clang/Driver/Options.td (+1)
- (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1)
- (modified) flang/include/flang/Common/Fortran-features.h (+1-1)
- (modified) flang/lib/Common/Fortran-features.cpp (+1)
- (modified) flang/lib/Frontend/CompilerInvocation.cpp (+6)
- (modified) flang/lib/Semantics/resolve-names.cpp (+2-1)
- (added) flang/test/Semantics/implicit17.f90 (+14)
``diff
diff --git a/clang/include/clang/Driver/Options.td
b/clang/include/clang/Driver/Options.td
index d8123cc39fdc95..c33fdb6a1c163d 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6876,6 +6876,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that
backslash in string in
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym
of .NEQV.">;
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable
logical abbreviations">;
defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing
allowed unless overridden by IMPLICIT statements">;
+defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit
externals allowed">;
defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing
underscore to external names">;
defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f",
"ppc-native-vector-element-order",
PosFlag,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp
b/clang/lib/Driver/ToolChains/Flang.cpp
index 1ae865f379110b..e4019c43496874 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,6 +42,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
options::OPT_fopenacc,
options::OPT_finput_charset_EQ,
options::OPT_fimplicit_none,
+options::OPT_fimplicit_none_ext,
options::OPT_fno_implicit_none,
options::OPT_fbackslash,
options::OPT_fno_backslash,
diff --git a/flang/include/flang/Common/Fortran-features.h
b/flang/include/flang/Common/Fortran-features.h
index 9549e8bfbbef0b..23c7afe9eec2bb 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Common/Fortran-features.h
@@ -54,7 +54,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy,
UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr,
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank,
-IgnoreIrrelevantAttributes, Unsigned)
+IgnoreIrrelevantAttributes, Unsigned, ImplicitNoneExternal)
// Portability and suspicious usage warnings
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
diff --git a/flang/lib/Common/Fortran-features.cpp
b/flang/lib/Common/Fortran-features.cpp
index 3565275915a312..678e2274960ac4 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Common/Fortran-features.cpp
@@ -22,6 +22,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
disable_.set(LanguageFeature::CudaUnified);
disable_.set(LanguageFeature::ImplicitNoneTypeNever);
disable_.set(LanguageFeature::ImplicitNoneTypeAlways);
+ disable_.set(LanguageFeature::ImplicitNoneExternal);
disable_.set(LanguageFeature::DefaultSave);
disable_.set(LanguageFeature::SaveMainProgram);
// These features, if enabled, conflict with valid standard usage,
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp
b/flang/lib/Frontend/CompilerInvocation.cpp
index 68b5950d3a51b7..a2c1d3efef6cf3 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -740,6 +740,12 @@ static bool parseFrontendArgs(FrontendOptions &opts,
llvm::opt::ArgList &args,
args.hasFlag(clang::driver::options::OPT_fimplicit_none,
clang::driver::options::OPT_fno_implicit_none, false));
+ // -f{no-}implicit-none-ext
+ opts.features.Enable(
+ Fortran::common::LanguageFeature::ImplicitNoneExternal,
+ args.hasFlag(clang::driver::options::OPT_fimplicit_none_ext,
+ clang::driver::options::OPT_fno_implicit_none_ext, false));
+
// -f{no-}backslash
opts.features.Enable(Fortran::common::LanguageFeature::BackslashEscapes,
args.hasFlag(clang::driver::options::OPT_fbackslash,
diff --git a/flang/lib/Seman
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/125248 ___ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [flang] [flang] Add support for -fimplicit-none-ext option (PR #125248)
https://github.com/eugeneepshteyn created
https://github.com/llvm/llvm-project/pull/125248
When -fimplicit-none-ext is passed, flang behaves as if "implicit
none(external)" was specified for all relevant constructs in Fortran source
file.
Note: implicit17.f90 was based on implicit07.f90 with `implicit none(external)`
removed and `-fimplicit-none-ext` added.
>From 11cb96c5dcb911a24596c646fbbc3cc6f3fd10a4 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn
Date: Fri, 31 Jan 2025 10:52:00 -0500
Subject: [PATCH 1/3] [flang] Add support for -fimplicit-none-ext option
When enabled, flang behaves as if "implicit none(external)" was specified for
all relevant constructs in Fortran source file.
Signed-off-by: Eugene Epshteyn
---
clang/include/clang/Driver/Options.td | 1 +
clang/lib/Driver/ToolChains/Flang.cpp | 1 +
flang/include/flang/Common/Fortran-features.h | 2 +-
flang/lib/Common/Fortran-features.cpp | 1 +
flang/lib/Frontend/CompilerInvocation.cpp | 7 +++
flang/lib/Semantics/resolve-names.cpp | 2 +-
6 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/Driver/Options.td
b/clang/include/clang/Driver/Options.td
index d8123cc39fdc951..c33fdb6a1c163d5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6876,6 +6876,7 @@ defm backslash : OptInFC1FFlag<"backslash", "Specify that
backslash in string in
defm xor_operator : OptInFC1FFlag<"xor-operator", "Enable .XOR. as a synonym
of .NEQV.">;
defm logical_abbreviations : OptInFC1FFlag<"logical-abbreviations", "Enable
logical abbreviations">;
defm implicit_none : OptInFC1FFlag<"implicit-none", "No implicit typing
allowed unless overridden by IMPLICIT statements">;
+defm implicit_none_ext : OptInFC1FFlag<"implicit-none-ext", "No implicit
externals allowed">;
defm underscoring : OptInFC1FFlag<"underscoring", "Appends one trailing
underscore to external names">;
defm ppc_native_vec_elem_order: BoolOptionWithoutMarshalling<"f",
"ppc-native-vector-element-order",
PosFlag,
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp
b/clang/lib/Driver/ToolChains/Flang.cpp
index 1ae865f379110bc..e4019c434968744 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,6 +42,7 @@ void Flang::addFortranDialectOptions(const ArgList &Args,
options::OPT_fopenacc,
options::OPT_finput_charset_EQ,
options::OPT_fimplicit_none,
+options::OPT_fimplicit_none_ext,
options::OPT_fno_implicit_none,
options::OPT_fbackslash,
options::OPT_fno_backslash,
diff --git a/flang/include/flang/Common/Fortran-features.h
b/flang/include/flang/Common/Fortran-features.h
index 9549e8bfbbef0bc..23c7afe9eec2bbf 100644
--- a/flang/include/flang/Common/Fortran-features.h
+++ b/flang/include/flang/Common/Fortran-features.h
@@ -54,7 +54,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
PolymorphicActualAllocatableOrPointerToMonomorphicDummy, RelaxedPureDummy,
UndefinableAsynchronousOrVolatileActual, AutomaticInMainProgram, PrintCptr,
SavedLocalInSpecExpr, PrintNamelist, AssumedRankPassedToNonAssumedRank,
-IgnoreIrrelevantAttributes, Unsigned)
+IgnoreIrrelevantAttributes, Unsigned, ImplicitNoneExternal)
// Portability and suspicious usage warnings
ENUM_CLASS(UsageWarning, Portability, PointerToUndefinable,
diff --git a/flang/lib/Common/Fortran-features.cpp
b/flang/lib/Common/Fortran-features.cpp
index 3565275915a3120..678e2274960ac4b 100644
--- a/flang/lib/Common/Fortran-features.cpp
+++ b/flang/lib/Common/Fortran-features.cpp
@@ -22,6 +22,7 @@ LanguageFeatureControl::LanguageFeatureControl() {
disable_.set(LanguageFeature::CudaUnified);
disable_.set(LanguageFeature::ImplicitNoneTypeNever);
disable_.set(LanguageFeature::ImplicitNoneTypeAlways);
+ disable_.set(LanguageFeature::ImplicitNoneExternal);
disable_.set(LanguageFeature::DefaultSave);
disable_.set(LanguageFeature::SaveMainProgram);
// These features, if enabled, conflict with valid standard usage,
diff --git a/flang/lib/Frontend/CompilerInvocation.cpp
b/flang/lib/Frontend/CompilerInvocation.cpp
index 68b5950d3a51b7b..e9ef308e987941a 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -740,6 +740,13 @@ static bool parseFrontendArgs(FrontendOptions &opts,
llvm::opt::ArgList &args,
args.hasFlag(clang::driver::options::OPT_fimplicit_none,
clang::driver::options::OPT_fno_implicit_none, false));
+ // -f{no-}implicit-none-ext
+ opts.features.Enable(
+ Fortran::common::LanguageFeature::ImplicitNoneExternal,
+ args.hasFlag(clang::driver::options::OPT_fimplicit_none_ext,
+ clang::driver::options::OPT_fno_implicit_no
