Don't give an error for 'try' and 'throw' if they occur in system headers.

llvm-svn: 126303
This commit is contained in:
Anders Carlsson 2011-02-23 03:46:46 +00:00
parent 34770edf43
commit d99dbcc2a9
2 changed files with 7 additions and 3 deletions

View File

@ -476,7 +476,9 @@ Sema::ActOnCXXNullPtrLiteral(SourceLocation Loc) {
/// ActOnCXXThrow - Parse throw expressions.
ExprResult
Sema::ActOnCXXThrow(SourceLocation OpLoc, Expr *Ex) {
if (!getLangOptions().Exceptions)
// Don't report an error if 'throw' is used in system headers.
if (!getLangOptions().Exceptions &&
!getSourceManager().isInSystemHeader(OpLoc))
Diag(OpLoc, diag::err_exceptions_disabled) << "throw";
if (Ex && !Ex->isTypeDependent() && CheckCXXThrowOperand(OpLoc, Ex))

View File

@ -1766,8 +1766,10 @@ public:
StmtResult
Sema::ActOnCXXTryBlock(SourceLocation TryLoc, Stmt *TryBlock,
MultiStmtArg RawHandlers) {
if (!getLangOptions().Exceptions)
Diag(TryLoc, diag::err_exceptions_disabled) << "try";
// Don't report an error if 'try' is used in system headers.
if (!getLangOptions().Exceptions &&
!getSourceManager().isInSystemHeader(TryLoc))
Diag(TryLoc, diag::err_exceptions_disabled) << "try";
unsigned NumHandlers = RawHandlers.size();
assert(NumHandlers > 0 &&