зеркало из https://github.com/microsoft/clang.git
Driver/Obj-C: Be compatible with GCC behavior in that -fno-exceptions *does not*
disable Obj-C exceptions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127836 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
617508fb9e
Коммит
d47ea69370
|
@ -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;
|
||||
// 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");
|
||||
|
||||
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);
|
||||
}
|
||||
ShouldUseExceptionTables |=
|
||||
shouldUseExceptionTablesForObjCExceptions(Args, Triple);
|
||||
}
|
||||
|
||||
if (types::isCXX(InputType)) {
|
||||
|
|
|
@ -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;
|
||||
}
|
Загрузка…
Ссылка в новой задаче