Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -2639,7 +2639,6 @@ defm real_8_real_10 : BooleanFFlag<"real-8-real-10">, Group<gfortran_Group>;
defm real_8_real_16 : BooleanFFlag<"real-8-real-16">, Group<gfortran_Group>;
defm real_8_real_4 : BooleanFFlag<"real-8-real-4">, Group<gfortran_Group>;
defm realloc_lhs : BooleanFFlag<"realloc-lhs">, Group<gfortran_Group>;
defm recursive : BooleanFFlag<"recursive">, Group<gfortran_Group>;
defm repack_arrays : BooleanFFlag<"repack-arrays">, Group<gfortran_Group>;
defm second_underscore : BooleanFFlag<"second-underscore">, Group<gfortran_Group>;
defm sign_zero : BooleanFFlag<"sign-zero">, Group<gfortran_Group>;
Expand Down Expand Up @@ -2680,7 +2679,10 @@ def pc: JoinedOrSeparate<["-"], "pc">, Group<pgi_fortran_Group>;
def Mfprelaxed: Joined<["-"], "Mfprelaxed">, Group<pgi_fortran_Group>;
def Mnofprelaxed: Joined<["-"], "Mnofprelaxed">, Group<pgi_fortran_Group>;
defm Mstride0: BooleanMFlag<"stride0">, Group<pgi_fortran_Group>;
defm Mrecursive: BooleanMFlag<"recursive">, Group<pgi_fortran_Group>;
def frecursive: Flag<["-"], "frecursive">, Group<gfortran_Group>;
def fno_recursive: Flag<["-"], "fno-recursive">, Group<gfortran_Group>;
def Mrecursive: Flag<["-"], "Mrecursive">, Group<pgi_fortran_Group>, Alias<frecursive>;
def Mnorecursive: Flag<["-"], "Mnorecursive">, Group<pgi_fortran_Group>, Alias<fno_recursive>;
defm Mreentrant: BooleanMFlag<"reentrant">, Group<pgi_fortran_Group>;
defm Mbounds: BooleanMFlag<"bounds">, Group<pgi_fortran_Group>;
def Mdaz_on: Flag<["-"], "Mdaz">, Group<pgi_fortran_Group>,
Expand Down
4 changes: 2 additions & 2 deletions lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,13 @@ void FlangFrontend::ConstructJob(Compilation &C, const JobAction &JA,
}

// Generate code allowing recursive subprograms
for (auto Arg : Args.filtered(options::OPT_Mrecursive_on)) {
for (auto Arg : Args.filtered(options::OPT_frecursive)) {
Arg->claim();
CommonCmdArgs.push_back("-recursive");
}

// Disable recursive subprograms
for (auto Arg : Args.filtered(options::OPT_Mrecursive_off)) {
for (auto Arg : Args.filtered(options::OPT_fno_recursive)) {
Arg->claim();
CommonCmdArgs.push_back("-norecursive");
}
Expand Down
29 changes: 29 additions & 0 deletions test/CodeGen/recursive.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
! RUN: %flang -O0 -frecursive -c %s -S -emit-llvm -o - | FileCheck -check-prefix=RECURSIVE %s
! RUN: %flang -O0 -fno-recursive -c %s -S -emit-llvm -o - | FileCheck -check-prefix=NORECURSIVE %s
! RUN: %flang -O0 -Mrecursive -c %s -S -emit-llvm -o - | FileCheck -check-prefix=RECURSIVE %s
! RUN: %flang -O0 -Mnorecursive -c %s -S -emit-llvm -o - | FileCheck -check-prefix=NORECURSIVE %s
PROGRAM RECURSIVE
IMPLICIT NONE
INTEGER FUN
EXTERNAL FUN
PRINT *, FUN(4, FUN)
END PROGRAM RECURSIVE

FUNCTION FUN(X, DUMMY)
IMPLICIT NONE
INTEGER FUN
INTEGER X
INTEGER DUMMY
EXTERNAL DUMMY
INTEGER ARRAY(4)
! RECURSIVE: %array_{{[0-9]+}} = alloca [4 x i32]
! RECURSIVE-NOT: BSS
! NORECURSIVE: BSS
! NORECURSIVE-NOT: %array_{{[0-9]+}} = alloca [4 x i32]

ARRAY = (/ X, 2, 3, 4 /)
IF (X .GT. 0) THEN
ARRAY(X) = DUMMY(X - 1, DUMMY)
ENDIF
FUN = ARRAY(1)
END FUNCTION