Frontend: Define __EXCEPTIONS if -fexceptions is passed

GCC defines __EXCEPTIONS, regardless of language mode, if -fexceptions
is passed.  We should do the same.

This fixes PR21358.

llvm-svn: 220714
This commit is contained in:
David Majnemer 2014-10-27 20:02:19 +00:00
parent 7ccebec668
commit 8ef921a48b
3 changed files with 7 additions and 4 deletions

View File

@ -550,7 +550,7 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__BLOCKS__");
}
if (!LangOpts.MSVCCompat && LangOpts.CXXExceptions)
if (!LangOpts.MSVCCompat && LangOpts.Exceptions)
Builder.defineMacro("__EXCEPTIONS");
if (!LangOpts.MSVCCompat && LangOpts.RTTI)
Builder.defineMacro("__GXX_RTTI");

View File

@ -1,6 +1,9 @@
// RUN: %clang_cc1 -fms-compatibility -fexceptions -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -fms-compatibility -fexceptions -fcxx-exceptions -DMS_MODE -verify %s
// expected-no-diagnostics
#if defined(__EXCEPTIONS)
// RUN: %clang_cc1 -fms-compatibility -fexceptions -verify %s
// expected-no-diagnostics
#if defined(MS_MODE) && defined(__EXCEPTIONS)
#error __EXCEPTIONS should not be defined.
#endif

View File

@ -1,6 +1,6 @@
// RUN: %clang_cc1 -x objective-c -fobjc-exceptions -fexceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-NOCXX %s
// CHECK-OBJC-NOCXX: #define OBJC_ZEROCOST_EXCEPTIONS 1
// CHECK-OBJC-NOCXX-NOT: #define __EXCEPTIONS 1
// CHECK-OBJC-NOCXX: #define __EXCEPTIONS 1
// RUN: %clang_cc1 -x objective-c++ -fobjc-exceptions -fexceptions -fcxx-exceptions -E -dM %s | FileCheck -check-prefix=CHECK-OBJC-CXX %s
// CHECK-OBJC-CXX: #define OBJC_ZEROCOST_EXCEPTIONS 1