From 7ebb4933750f008dfdaecc8b927024b794aa4b9b Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 9 May 2012 05:35:08 +0000 Subject: Teach IsTailPaddedMemberArray() (used by -Warray-bounds) that a FieldDecl may have a Typedef type, and not always a ConstantArrayType. Fixes . llvm-svn: 156464 --- clang/lib/Sema/SemaChecking.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'clang/lib/Sema') diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index d538fcf36d6..bc4452f125d 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4590,12 +4590,20 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size, // substitution to form C89 tail-padded arrays. TypeSourceInfo *TInfo = FD->getTypeSourceInfo(); - if (TInfo) { - ConstantArrayTypeLoc TL = - cast(TInfo->getTypeLoc()); - const Expr *SizeExpr = dyn_cast(TL.getSizeExpr()); + while (TInfo) { + TypeLoc TL = TInfo->getTypeLoc(); + // Look through typedefs. + const TypedefTypeLoc *TTL = dyn_cast(&TL); + if (TTL) { + const TypedefNameDecl *TDL = TTL->getTypedefNameDecl(); + TInfo = TDL->getTypeSourceInfo(); + continue; + } + ConstantArrayTypeLoc CTL = cast(TL); + const Expr *SizeExpr = dyn_cast(CTL.getSizeExpr()); if (!SizeExpr || SizeExpr->getExprLoc().isMacroID()) return false; + break; } const RecordDecl *RD = dyn_cast(FD->getDeclContext()); -- cgit v1.2.3