[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new
David Truby via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 19 07:57:19 PDT 2023
DavidTruby created this revision.
DavidTruby added reviewers: tblah, vzakhari, awarzynski.
Herald added a reviewer: sscalpone.
Herald added a subscriber: sunshaoce.
Herald added projects: Flang, All.
DavidTruby requested review of this revision.
Herald added subscribers: cfe-commits, jdoerfert, MaskRay.
Herald added a project: clang.
This flag enables Fortran 2003 polymorphism. It is marked experimental
and not included in --help.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153281
Files:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/flang-experimental-polymorphism-flag.f90
Index: flang/test/Driver/flang-experimental-polymorphism-flag.f90
===================================================================
--- /dev/null
+++ flang/test/Driver/flang-experimental-polymorphism-flag.f90
@@ -0,0 +1,10 @@
+! Test -flang-experimental-hlfir flag
+! RUN: %flang_fc1 -flang-experimental-polymorphism -emit-fir -o - %s | FileCheck %s
+! RUN: not %flang_fc1 -emit-fir -o - %s 2>&1 | FileCheck %s --check-prefix NO-POLYMORPHISM
+
+! CHECK: func.func @_QPtest(%{{.*}}: !fir.class<none> {fir.bindc_name = "poly"})
+subroutine test(poly)
+ class(*) :: poly
+end subroutine test
+
+! NO-POLYMORPHISM: not yet implemented: support for polymorphic types
Index: flang/test/Driver/driver-help-hidden.f90
===================================================================
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -43,6 +43,8 @@
! CHECK-NEXT: Enable support for generating executables (experimental)
! CHECK-NEXT: -flang-experimental-hlfir
! CHECK-NEXT: Use HLFIR lowering (experimental)
+! CHECK-NEXT: -flang-experimental-polymorphism
+! CHECK-NEXT: Enable Fortran 2003 polymorphism (experimental)
! CHECK-NEXT: -flarge-sizes Use INTEGER(KIND=8) for the result type in size-related intrinsics
! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
! CHECK-NEXT: -flto=<value> Set LTO mode
Index: flang/lib/Frontend/CompilerInvocation.cpp
===================================================================
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -920,6 +920,10 @@
res.loweringOpts.setLowerToHighLevelFIR(true);
}
+ if (args.hasArg(clang::driver::options::OPT_flang_experimental_polymorphism)) {
+ res.loweringOpts.setPolymorphicTypeImpl(true);
+ }
+
success &= parseFrontendArgs(res.getFrontendOpts(), args, diags);
parseTargetArgs(res.getTargetOpts(), args);
parsePreprocessorArgs(res.getPreprocessorOpts(), args);
Index: clang/lib/Driver/ToolChains/Flang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -140,6 +140,8 @@
if (Args.hasArg(options::OPT_flang_experimental_hlfir))
CmdArgs.push_back("-flang-experimental-hlfir");
+ if (Args.hasArg(options::OPT_flang_experimental_polymorphism))
+ CmdArgs.push_back("-flang-experimental-polymorphism");
if (shouldLoopVersion(Args))
CmdArgs.push_back("-fversion-loops-for-stride");
}
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -5289,6 +5289,11 @@
Flags<[FlangOption, FC1Option, FlangOnlyOption, NoXarchOption, HelpHidden]>,
HelpText<"Use HLFIR lowering (experimental)">;
+def flang_experimental_polymorphism : Flag<["-"], "flang-experimental-polymorphism">,
+ Flags<[FlangOption, FC1Option, FlangOnlyOption, NoXarchOption, HelpHidden]>,
+ HelpText<"Enable Fortran 2003 polymorphism (experimental)">;
+
+
//===----------------------------------------------------------------------===//
// FLangOption + CoreOption + NoXarchOption
//===----------------------------------------------------------------------===//
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153281.532658.patch
Type: text/x-patch
Size: 3396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230619/42b0f42c/attachment-0001.bin>
More information about the cfe-commits
mailing list