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
10 changes: 4 additions & 6 deletions clang/include/clang/Options/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -7236,11 +7236,14 @@ def cpp : Flag<["-"], "cpp">, Group<f_Group>,
HelpText<"Enable predefined and command line preprocessor macros">;
def nocpp : Flag<["-"], "nocpp">, Group<f_Group>,
HelpText<"Disable predefined and command line preprocessor macros">;
def module_dir : JoinedOrSeparate<["-"], "module-dir">, MetaVarName<"<dir>">,
def J : JoinedOrSeparate<["-"], "J">,
Flags<[RenderJoined]>,
HelpText<"Put MODULE files in <dir>">,
DocBrief<[{This option specifies where to put .mod files for compiled modules.
It is also added to the list of directories to be searched by an USE statement.
The default is the current directory.}]>;
def module_dir : Separate<["-"], "module-dir">, MetaVarName<"<dir>">,
Alias<J>;

def ffixed_form : Flag<["-"], "ffixed-form">, Group<f_Group>,
HelpText<"Process source files in fixed form">;
Expand Down Expand Up @@ -7376,11 +7379,6 @@ def fdo_concurrent_to_openmp_EQ : Joined<["-"], "fdo-concurrent-to-openmp=">,
Values<"none, host, device">;
} // let Visibility = [FC1Option, FlangOption]

def J : JoinedOrSeparate<["-"], "J">,
Flags<[RenderJoined]>, Visibility<[FlangOption, FC1Option]>,
Group<gfortran_Group>,
Alias<module_dir>;

//===----------------------------------------------------------------------===//
// FC1 Options
//===----------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Flang::addDebugOptions(const llvm::opt::ArgList &Args, const JobAction &JA,
const auto &TC = getToolChain();
const Driver &D = TC.getDriver();
Args.addAllArgs(CmdArgs,
{options::OPT_module_dir, options::OPT_fdebug_module_writer,
{options::OPT_J, options::OPT_fdebug_module_writer,
options::OPT_fintrinsic_modules_path, options::OPT_pedantic,
options::OPT_std_EQ, options::OPT_W_Joined,
options::OPT_fconvert_EQ, options::OPT_fpass_plugin_EQ,
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ static bool parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,

// -J/module-dir option
std::vector<std::string> moduleDirList =
args.getAllArgValues(clang::options::OPT_module_dir);
args.getAllArgValues(clang::options::OPT_J);
// User can only specify one -J/-module-dir directory, but may repeat
// -J/-module-dir as long as the directory is the same each time.
// https://gcc.gnu.org/onlinedocs/gfortran/Directory-Options.html
Expand Down
23 changes: 14 additions & 9 deletions flang/test/Driver/write-module.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
! * is saved in the _directory specified by the user_
! We use `-fsyntax-only` as it stops after the semantic checks (the module file is generated when sema checks are run)

! ------------------------------------------------------------------------------
! At one time, flang accepted -module-dir<value> (note the lack of a separator
! between -module-dir and <value>). This is no longer allowed.
! -module-dir=<value> is also not allowed
!
! RUN: not %flang -fsyntax-only -module-dir%t %s 2>&1 \
! RUN: | FileCheck %s -check-prefix=JOINED
!
! RUN: not %flang -fsyntax-only -module-dir=%t %s 2>&1 \
! RUN: | FileCheck %s -check-prefix=JOINED
!
! JOINED: error: unknown argument: '-module-dir{{.+}}'
!
!--------------------------
! -module-dir <value>
!--------------------------
! RUN: rm -rf %t && mkdir -p %t/dir-flang
! RUN: cd %t && %flang -fsyntax-only -module-dir %t/dir-flang %s
! RUN: ls %t/dir-flang/testmodule.mod && not ls %t/testmodule.mod
! RUN: cd -

!--------------------------
! -module-dir<value>
!--------------------------
! RUN: rm -rf %t && mkdir -p %t/dir-flang
! RUN: cd %t && %flang -fsyntax-only -module-dir%t/dir-flang %s
! RUN: ls %t/dir-flang/testmodule.mod && not ls %t/testmodule.mod
! RUN: cd -

!
!---------------------------
! -J <value>
!---------------------------
Expand Down
Loading