diff options
author | Anders Carlsson <andersca@mac.com> | 2011-02-19 19:26:44 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2011-02-19 19:26:44 +0000 |
commit | 7f11d9cf5df1f8ce82af46eabc4ec5cec7d580b0 (patch) | |
tree | a870ff25e6a7304d663f1a819110a41bb3e8c769 /lib/Sema | |
parent | d9ea180032eda76a46c099a9aab99512447c326d (diff) |
Disallow try/catch/throw when exceptions are disabled.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126039 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 3 | ||||
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 9113f8a462..07e6b6f14b 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index ba50824c1b..523fc4a852 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/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."); |