From bc6aaea3364729cbd29a114e9e1f62ebe34defe3 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 25 Jan 2017 03:36:28 +0000 Subject: Driver: ignore -fno-objc-arc-exception when -fno-objc-arc set Sometime clang would be supplied -fobjc-arc -f(no)objc-arc-exceptions and then later disable ARC with -fno-objc-arc, which only negate first option, but not the latter, resulting usused argument warning. Silence this warning only when -fno-objc-arc option is present. Patch by Onha Choe! llvm-svn: 293014 --- clang/lib/Driver/Tools.cpp | 6 ++++++ clang/test/Driver/no-arc-exception-silence.m | 2 ++ 2 files changed, 8 insertions(+) create mode 100644 clang/test/Driver/no-arc-exception-silence.m (limited to 'clang') diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index c78123b236d..854b5d5cccb 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -6018,7 +6018,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, options::OPT_fno_objc_arc_exceptions, /*default*/ types::isCXX(InputType))) CmdArgs.push_back("-fobjc-arc-exceptions"); + } + // Silence warning for full exception code emission options when explicitly + // set to use no ARC. + if (Args.hasArg(options::OPT_fno_objc_arc)) { + Args.ClaimAllArgs(options::OPT_fobjc_arc_exceptions); + Args.ClaimAllArgs(options::OPT_fno_objc_arc_exceptions); } // -fobjc-infer-related-result-type is the default, except in the Objective-C diff --git a/clang/test/Driver/no-arc-exception-silence.m b/clang/test/Driver/no-arc-exception-silence.m new file mode 100644 index 00000000000..96b700d8352 --- /dev/null +++ b/clang/test/Driver/no-arc-exception-silence.m @@ -0,0 +1,2 @@ +// RUN: %clang -Werror -fobjc-arc -fobjc-arc-exceptions -fno-objc-arc -Xclang -verify -c %s +// expected-no-diagnostics -- cgit v1.2.3