diff options
-rw-r--r-- | lib/Driver/Tools.cpp | 29 | ||||
-rw-r--r-- | test/Driver/exceptions.m | 19 |
2 files changed, 29 insertions, 19 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index cf6a853952..45fdd8be2e 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -843,25 +843,16 @@ static void addExceptionArgs(const ArgList &Args, types::ID InputType, if (ExceptionsEnabled && DidHaveExplicitExceptionFlag) ShouldUseExceptionTables = true; - if (types::isObjC(InputType)) { - bool ObjCExceptionsEnabled = ExceptionsEnabled; - - if (Arg *A = Args.getLastArg(options::OPT_fobjc_exceptions, - options::OPT_fno_objc_exceptions, - options::OPT_fexceptions, - options::OPT_fno_exceptions)) { - if (A->getOption().matches(options::OPT_fobjc_exceptions)) - ObjCExceptionsEnabled = true; - else if (A->getOption().matches(options::OPT_fno_objc_exceptions)) - ObjCExceptionsEnabled = false; - } - - if (ObjCExceptionsEnabled) { - CmdArgs.push_back("-fobjc-exceptions"); - - ShouldUseExceptionTables |= - shouldUseExceptionTablesForObjCExceptions(Args, Triple); - } + // Obj-C exceptions are enabled by default, regardless of -fexceptions. This + // is not necessarily sensible, but follows GCC. + if (types::isObjC(InputType) && + Args.hasFlag(options::OPT_fobjc_exceptions, + options::OPT_fno_objc_exceptions, + true)) { + CmdArgs.push_back("-fobjc-exceptions"); + + ShouldUseExceptionTables |= + shouldUseExceptionTablesForObjCExceptions(Args, Triple); } if (types::isCXX(InputType)) { diff --git a/test/Driver/exceptions.m b/test/Driver/exceptions.m new file mode 100644 index 0000000000..7d85fe30ae --- /dev/null +++ b/test/Driver/exceptions.m @@ -0,0 +1,19 @@ +// RUN: %clang -ccc-host-triple x86_64-apple-darwin9 \ +// RUN: -fsyntax-only -fno-exceptions %s + +void f1() { + @throw @"A"; +} + +void f0() { + @try { + f1(); + } @catch (id x) { + ; + } +} + +int main() { + f0(); + return 0; +} |