From 16446f30e738aebd31a9d3b1ff81661a395c1553 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 27 Oct 2014 20:02:19 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220714 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Frontend/InitPreprocessor.cpp | 2 +- test/Frontend/exceptions.c | 7 +++++-- test/Preprocessor/predefined-exceptions.m | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 802b2a95cc..476e214232 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -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"); diff --git a/test/Frontend/exceptions.c b/test/Frontend/exceptions.c index 4bbaaa39bf..981b5b9045 100644 --- a/test/Frontend/exceptions.c +++ b/test/Frontend/exceptions.c @@ -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 diff --git a/test/Preprocessor/predefined-exceptions.m b/test/Preprocessor/predefined-exceptions.m index c13f429e37..0791075dfc 100644 --- a/test/Preprocessor/predefined-exceptions.m +++ b/test/Preprocessor/predefined-exceptions.m @@ -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 -- 2.40.0