diff --git a/clang/include/clang/Driver/Options.def b/clang/include/clang/Driver/Options.def index 7e77a1a51cbd..bfa5a664ee83 100644 --- a/clang/include/clang/Driver/Options.def +++ b/clang/include/clang/Driver/Options.def @@ -424,11 +424,11 @@ OPTION("-fasm-blocks", fasm_blocks, Flag, clang_ignored_f_Group, INVALID, "", 0, OPTION("-fastcp", fastcp, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fastf", fastf, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fast", fast, Flag, f_Group, INVALID, "", 0, 0, 0) -OPTION("-fblocks", fblocks, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fblocks", fblocks, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fbootclasspath=", fbootclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) -OPTION("-fbuiltin", fbuiltin, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fbuiltin", fbuiltin, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fclasspath=", fclasspath_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) -OPTION("-fcommon", fcommon, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fcommon", fcommon, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fcompile-resource=", fcompile_resource_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) OPTION("-fconstant-cfstrings", fconstant_cfstrings, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) OPTION("-fcreate-profile", fcreate_profile, Flag, f_Group, INVALID, "", 0, 0, 0) @@ -459,10 +459,10 @@ OPTION("-fmudflapth", fmudflapth, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fmudflap", fmudflap, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fnested-functions", fnested_functions, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fnext-runtime", fnext_runtime, Flag, clang_f_Group, INVALID, "", 0, 0, 0) -OPTION("-fno-blocks", fno_blocks, Flag, clang_f_Group, INVALID, "", 0, 0, 0) -OPTION("-fno-builtin", fno_builtin, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-blocks", fno_blocks, Flag, f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-builtin", fno_builtin, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-caret-diagnostics", fno_caret_diagnostics, Flag, clang_f_Group, INVALID, "", 0, 0, 0) -OPTION("-fno-common", fno_common, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fno-common", fno_common, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-constant-cfstrings", fno_constant_cfstrings, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-eliminate-unused-debug-symbols", fno_eliminate_unused_debug_symbols, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fno-inline-functions", fno_inline_functions, Flag, clang_ignored_f_Group, INVALID, "", 0, 0, 0) @@ -488,7 +488,7 @@ OPTION("-fopenmp", fopenmp, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-force_cpusubtype_ALL", force__cpusubtype__ALL, Flag, INVALID, INVALID, "", 0, 0, 0) OPTION("-force_flat_namespace", force__flat__namespace, Flag, INVALID, INVALID, "", 0, 0, 0) OPTION("-foutput-class-dir=", foutput_class_dir_EQ, Joined, f_Group, INVALID, "", 0, 0, 0) -OPTION("-fpascal-strings", fpascal_strings, Flag, clang_f_Group, INVALID, "", 0, 0, 0) +OPTION("-fpascal-strings", fpascal_strings, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fpch-preprocess", fpch_preprocess, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fpic", fpic, Flag, f_Group, INVALID, "", 0, 0, 0) OPTION("-fpie", fpie, Flag, f_Group, INVALID, "", 0, 0, 0) diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index e26bb9e85adf..dd3a00ecb338 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -357,8 +357,34 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back(A->getValue(Args)); } + // Forward -f options which we can pass directly. Args.AddAllArgs(CmdArgs, options::OPT_clang_f_Group); + // Forward -f options with positive and negative forms; we translate + // these by hand. + + // -fbuiltin is default, only pass non-default. + if (!Args.hasFlag(options::OPT_fbuiltin, options::OPT_fno_builtin)) + CmdArgs.push_back("-fbuiltin=0"); + + // -fblocks default varies depending on platform and language; + // -always pass if specified. + if (Arg *A = Args.getLastArg(options::OPT_fblocks, options::OPT_fno_blocks)) { + if (A->getOption().matches(options::OPT_fblocks)) + CmdArgs.push_back("-fblocks"); + else + CmdArgs.push_back("-fblocks=0"); + } + + // -fno-pascal-strings is default, only pass non-default. + if (Args.hasFlag(options::OPT_fpascal_strings, + options::OPT_fno_pascal_strings)) + CmdArgs.push_back("-fpascal-strings"); + + // -fcommon is default, only pass non-default. + if (!Args.hasFlag(options::OPT_fcommon, options::OPT_fno_common)) + CmdArgs.push_back("-fno-common"); + // If tool chain translates fpascal-strings, we want to back // translate here. // FIXME: This is gross; that translation should be pulled from the diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c index ae4c37cd469e..9db8c9248de3 100644 --- a/clang/test/Sema/exprs.c +++ b/clang/test/Sema/exprs.c @@ -1,4 +1,4 @@ -// RUN: clang-cc %s -verify -pedantic -fsyntax-only -fno-blocks +// RUN: clang-cc %s -verify -pedantic -fsyntax-only -fblocks=0 // PR1966 _Complex double test1() { diff --git a/clang/test/Sema/unused-expr.c b/clang/test/Sema/unused-expr.c index b3d6efb7d374..9c231e960a2a 100644 --- a/clang/test/Sema/unused-expr.c +++ b/clang/test/Sema/unused-expr.c @@ -1,4 +1,4 @@ -// RUN: clang-cc -fsyntax-only -verify -fno-math-errno %s +// RUN: clang-cc -fsyntax-only -verify -fmath-errno=0 %s int foo(int X, int Y); diff --git a/clang/tools/clang-cc/clang-cc.cpp b/clang/tools/clang-cc/clang-cc.cpp index d257c432fc6d..9260afe4b7db 100644 --- a/clang/tools/clang-cc/clang-cc.cpp +++ b/clang/tools/clang-cc/clang-cc.cpp @@ -323,15 +323,13 @@ Freestanding("ffreestanding", "freestanding environment")); static llvm::cl::opt -AllowBuiltins("fbuiltin", - llvm::cl::desc("Disable implicit builtin knowledge of functions"), - llvm::cl::init(true), llvm::cl::AllowInverse); +AllowBuiltins("fbuiltin", llvm::cl::init(true), + llvm::cl::desc("Disable implicit builtin knowledge of functions")); static llvm::cl::opt -MathErrno("fmath-errno", - llvm::cl::desc("Require math functions to respect errno"), - llvm::cl::init(true), llvm::cl::AllowInverse); +MathErrno("fmath-errno", llvm::cl::init(true), + llvm::cl::desc("Require math functions to respect errno")); //===----------------------------------------------------------------------===// // Language Options @@ -546,9 +544,7 @@ NoLaxVectorConversions("fno-lax-vector-conversions", "elements or different element types")); static llvm::cl::opt -EnableBlocks("fblocks", llvm::cl::desc("enable the 'blocks' language feature"), - llvm::cl::ValueDisallowed, llvm::cl::AllowInverse, - llvm::cl::ZeroOrMore); +EnableBlocks("fblocks", llvm::cl::desc("enable the 'blocks' language feature")); static llvm::cl::opt EnableHeinousExtensions("fheinous-gnu-extensions",