From: Chad Rosier Date: Wed, 6 Feb 2013 00:58:34 +0000 (+0000) Subject: Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5e25301c24c92a9b7018cee20e524c4eb7192bf0;p=clang Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc. rdar://13153516 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174477 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8db183105e..800f64cd5c 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -5777,10 +5777,11 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size, TInfo = TDL->getTypeSourceInfo(); continue; } - ConstantArrayTypeLoc CTL = cast(TL); - const Expr *SizeExpr = dyn_cast(CTL.getSizeExpr()); - if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) - return false; + if (const ConstantArrayTypeLoc *CTL = dyn_cast(&TL)) { + const Expr *SizeExpr = dyn_cast(CTL->getSizeExpr()); + if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) + return false; + } break; }