summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-02-19 19:26:44 +0000
committerAnders Carlsson <andersca@mac.com>2011-02-19 19:26:44 +0000
commit68b36aff4676354413cd29569f3f43f68152eb15 (patch)
treea19018953f6ac7a19e1a150f016a3d0c93bb799b /clang/lib/Sema
parentbf2b26d805d62ea214c96eac6bfd806ad733fe64 (diff)
downloadbcm5719-llvm-68b36aff4676354413cd29569f3f43f68152eb15.tar.gz
bcm5719-llvm-68b36aff4676354413cd29569f3f43f68152eb15.zip
Disallow try/catch/throw when exceptions are disabled.
llvm-svn: 126039
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp3
-rw-r--r--clang/lib/Sema/SemaStmt.cpp3
2 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 9113f8a4621..07e6b6f14b1 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -476,6 +476,9 @@ Sema::ActOnCXXNullPtrLiteral(SourceLocation Loc) {
/// ActOnCXXThrow - Parse throw expressions.
ExprResult
Sema::ActOnCXXThrow(SourceLocation OpLoc, Expr *Ex) {
+ if (!getLangOptions().Exceptions)
+ return Diag(OpLoc, diag::err_exceptions_disabled) << "throw";
+
if (Ex && !Ex->isTypeDependent() && CheckCXXThrowOperand(OpLoc, Ex))
return ExprError();
return Owned(new (Context) CXXThrowExpr(Ex, Context.VoidTy, OpLoc));
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index ba50824c1bd..523fc4a852c 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -1741,6 +1741,9 @@ public:
StmtResult
Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
MultiStmtArg RawHandlers) {
+ if (!getLangOptions().Exceptions)
+ return Diag(TryLoc, diag::err_exceptions_disabled) << "try";
+
unsigned NumHandlers = RawHandlers.size();
assert(NumHandlers > 0 &&
"The parser shouldn't call this if there are no handlers.");
OpenPOWER on IntegriCloud