summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp3
-rw-r--r--clang/test/Lexer/has_feature_exceptions.cpp11
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 6181e17e602..25f8b113c34 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -488,6 +488,9 @@ static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II) {
return false;
case 8:
if (II->isStr("cxx_rtti")) return LangOpts.RTTI;
+ return false;
+ case 14:
+ if (II->isStr("cxx_exceptions")) return LangOpts.Exceptions;
return false;
case 19:
if (II->isStr("objc_nonfragile_abi")) return LangOpts.ObjCNonFragileABI;
diff --git a/clang/test/Lexer/has_feature_exceptions.cpp b/clang/test/Lexer/has_feature_exceptions.cpp
new file mode 100644
index 00000000000..231a6c56a45
--- /dev/null
+++ b/clang/test/Lexer/has_feature_exceptions.cpp
@@ -0,0 +1,11 @@
+// RUN: clang -E -fexceptions %s -o - | FileCheck --check-prefix=CHECK-EXCEPTIONS %s
+// RUN: clang -E -fno-exceptions %s -o - | FileCheck --check-prefix=CHECK-NO-EXCEPTIONS %s
+
+#if __has_feature(cxx_exceptions)
+int foo();
+#else
+int bar();
+#endif
+
+// CHECK-EXCEPTIONS: foo
+// CHECK-NO-EXCEPTIONS: bar
OpenPOWER on IntegriCloud