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 | 5f623229ecb37218f463f43def51e4b0807d6077 (patch) | |
tree | a91d5a2b2ac309fb311035b1f58db321593068ac /clang/lib/Sema/SemaChecking.cpp | |
parent | 5e2192adb592492d7b42f1a2831bed7a8585e604 (diff) | |
download | bcm5719-llvm-5f623229ecb37218f463f43def51e4b0807d6077.tar.gz bcm5719-llvm-5f623229ecb37218f463f43def51e4b0807d6077.zip |
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);
}
llvm-svn: 145918
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 1ec7e39398b..869922faf42 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/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. |