]> granicus.if.org Git - clang/commitdiff
Don't give an error for 'try' and 'throw' if they occur in system headers.
authorAnders Carlsson <andersca@mac.com>
Wed, 23 Feb 2011 03:46:46 +0000 (03:46 +0000)
committerAnders Carlsson <andersca@mac.com>
Wed, 23 Feb 2011 03:46:46 +0000 (03:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126303 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
lib/Sema/SemaStmt.cpp

index f9c2c9a62ea3c312322dbe2ffc7aabff59a64ae3..a051661285d62ad84d539ff9d438021a21c0437a 100644 (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))
index 0abd79a696f8e876fc2d43e31113de6738a5cec7..64827ff17797e863b7e4c328f7e234c516a49377 100644 (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 &&