From 70299928079fe7d372e0b934dfcaaae6c947f193 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 6 Feb 2013 00:58:34 +0000 Subject: [PATCH] Use a dyn_cast to avoid a crash when the TypeLoc is not a ConstantArrayTypeLoc. rdar://13153516 llvm-svn: 174477 --- clang/lib/Sema/SemaChecking.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 8db183105e52..800f64cd5cdc 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/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; }