diff options
author | Richard Trieu <rtrieu@google.com> | 2011-12-06 04:48:01 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2011-12-06 04:48:01 +0000 |
commit | 26b45d86085a125af036dbcf85dad3087b664ab2 (patch) | |
tree | d197d99f6871cbe62bc1a5ef07c4808c55a58e4c /lib/Sema/SemaChecking.cpp | |
parent | 55e983c0200cb39899652c6e741d6583edce4439 (diff) |
Switch a cast to a dyn_cast and check the pointer before using. Fixes a crash
in the following code:
void test4(bool (&x)(void)) {
while (x);
}
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@145918 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 1ec7e39398..869922faf4 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -3771,10 +3771,11 @@ void CheckImplicitConversion(Sema &S, Expr *E, QualType T, } if (D && !D->isWeak()) { - FunctionDecl* F = cast<FunctionDecl>(D); - S.Diag(E->getExprLoc(), diag::warn_impcast_function_to_bool) - << F << E->getSourceRange() << SourceRange(CC); - return; + if (FunctionDecl* F = dyn_cast<FunctionDecl>(D)) { + S.Diag(E->getExprLoc(), diag::warn_impcast_function_to_bool) + << F << E->getSourceRange() << SourceRange(CC); + return; + } } } return; // Other casts to bool are not checked. |