forked from OSchip/llvm-project
Driver: Fix forwarding of -{std,ansi,trigraphs} when there are
multiple instances of an option. Also, removed direct -ansi support from clang-cc. llvm-svn: 68558
This commit is contained in:
parent
5f50c651e9
commit
c44b4ccca8
|
@ -350,8 +350,23 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
Args.AddAllArgs(CmdArgs, options::OPT_clang_W_Group,
|
Args.AddAllArgs(CmdArgs, options::OPT_clang_W_Group,
|
||||||
options::OPT_pedantic_Group);
|
options::OPT_pedantic_Group);
|
||||||
Args.AddLastArg(CmdArgs, options::OPT_w);
|
Args.AddLastArg(CmdArgs, options::OPT_w);
|
||||||
Args.AddAllArgs(CmdArgs, options::OPT_std_EQ, options::OPT_ansi,
|
|
||||||
options::OPT_trigraphs);
|
// Handle -{std, ansi, trigraphs} -- take the last of -{std, ansi}
|
||||||
|
// (-ansi is equivalent to -std=c89).
|
||||||
|
//
|
||||||
|
// If a std is supplied, only add -trigraphs if it follows the
|
||||||
|
// option.
|
||||||
|
if (Arg *Std = Args.getLastArg(options::OPT_std_EQ, options::OPT_ansi)) {
|
||||||
|
if (Std->getOption().matches(options::OPT_ansi))
|
||||||
|
CmdArgs.push_back("-std=c89");
|
||||||
|
else
|
||||||
|
Std->render(Args, CmdArgs);
|
||||||
|
|
||||||
|
if (Arg *A = Args.getLastArg(options::OPT_trigraphs))
|
||||||
|
if (A->getIndex() > Std->getIndex())
|
||||||
|
A->render(Args, CmdArgs);
|
||||||
|
} else
|
||||||
|
Args.AddLastArg(CmdArgs, options::OPT_trigraphs);
|
||||||
|
|
||||||
if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) {
|
if (Arg *A = Args.getLastArg(options::OPT_ftemplate_depth_)) {
|
||||||
CmdArgs.push_back("-ftemplate-depth");
|
CmdArgs.push_back("-ftemplate-depth");
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// RUN: clang -std=c99 -trigraphs -std=gnu99 %s -E -o %t &&
|
||||||
|
// RUN: grep '??(??)' %t &&
|
||||||
|
// RUN: clang -ansi %s -E -o %t &&
|
||||||
|
// RUN: grep -F '[]' %t &&
|
||||||
|
// RUN: clang -std=gnu99 -trigraphs %s -E -o %t &&
|
||||||
|
// RUN: grep -F '[]' %t
|
||||||
|
|
||||||
|
??(??)
|
|
@ -585,9 +585,6 @@ NeXTRuntime("fnext-runtime",
|
||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences."));
|
Trigraphs("trigraphs", llvm::cl::desc("Process trigraph sequences."));
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
|
||||||
Ansi("ansi", llvm::cl::desc("Equivalent to specifying -std=c89."));
|
|
||||||
|
|
||||||
static llvm::cl::list<std::string>
|
static llvm::cl::list<std::string>
|
||||||
TargetFeatures("mattr", llvm::cl::CommaSeparated,
|
TargetFeatures("mattr", llvm::cl::CommaSeparated,
|
||||||
llvm::cl::desc("Target specific attributes (-mattr=help for details)"));
|
llvm::cl::desc("Target specific attributes (-mattr=help for details)"));
|
||||||
|
@ -653,9 +650,6 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ansi) // "The -ansi option is equivalent to -std=c89."
|
|
||||||
LangStd = lang_c89;
|
|
||||||
|
|
||||||
if (LangStd == lang_unspecified) {
|
if (LangStd == lang_unspecified) {
|
||||||
// Based on the base language, pick one.
|
// Based on the base language, pick one.
|
||||||
switch (LK) {
|
switch (LK) {
|
||||||
|
@ -719,8 +713,8 @@ static void InitializeLanguageStandard(LangOptions &Options, LangKind LK,
|
||||||
else
|
else
|
||||||
Options.ImplicitInt = 0;
|
Options.ImplicitInt = 0;
|
||||||
|
|
||||||
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs or -ansi
|
// Mimicing gcc's behavior, trigraphs are only enabled if -trigraphs
|
||||||
// is specified, or -std is set to a conforming mode.
|
// is specified, or -std is set to a conforming mode.
|
||||||
Options.Trigraphs = !Options.GNUMode;
|
Options.Trigraphs = !Options.GNUMode;
|
||||||
if (Trigraphs.getPosition())
|
if (Trigraphs.getPosition())
|
||||||
Options.Trigraphs = Trigraphs; // Command line option wins if specified.
|
Options.Trigraphs = Trigraphs; // Command line option wins if specified.
|
||||||
|
|
Loading…
Reference in New Issue