From 5f623229ecb37218f463f43def51e4b0807d6077 Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Tue, 6 Dec 2011 04:48:01 +0000 Subject: 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 --- clang/lib/Sema/SemaChecking.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema/SemaChecking.cpp') 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(D); - S.Diag(E->getExprLoc(), diag::warn_impcast_function_to_bool) - << F << E->getSourceRange() << SourceRange(CC); - return; + if (FunctionDecl* F = dyn_cast(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. -- cgit v1.2.3