Index: clang/lib/Sema/AnalysisBasedWarnings.cpp =================================================================== --- clang/lib/Sema/AnalysisBasedWarnings.cpp +++ clang/lib/Sema/AnalysisBasedWarnings.cpp @@ -289,14 +289,14 @@ static bool isThrowCaught(const CXXThrowExpr *Throw, const CXXCatchStmt *Catch) { + const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull(); + if (!CaughtType) + return true; const Type *ThrowType = nullptr; if (Throw->getSubExpr()) ThrowType = Throw->getSubExpr()->getType().getTypePtrOrNull(); if (!ThrowType) return false; - const Type *CaughtType = Catch->getCaughtType().getTypePtrOrNull(); - if (!CaughtType) - return true; if (ThrowType->isReferenceType()) ThrowType = ThrowType->castAs() ->getPointeeType() Index: clang/test/SemaCXX/warn-throw-out-noexcept-func.cpp =================================================================== --- clang/test/SemaCXX/warn-throw-out-noexcept-func.cpp +++ clang/test/SemaCXX/warn-throw-out-noexcept-func.cpp @@ -239,9 +239,9 @@ } catch (const S &s) { } } -void o_ShouldDiag() noexcept { //expected-note {{function declared non-throwing here}} +void o_ShouldNotDiag() noexcept { try { - throw; //expected-warning {{has a non-throwing exception specification but}} + throw; } catch (...) { } }