From c93b489138173d2ea3fc3d1f6f8a52e6b6dd200f Mon Sep 17 00:00:00 2001 From: Matt Beaumont-Gay Date: Tue, 29 Nov 2011 22:43:53 +0000 Subject: Suppress -Warray-bounds for classes (not just structs) where the last field is a 1-length character array. llvm-svn: 145445 --- clang/lib/Sema/SemaChecking.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'clang/lib/Sema/SemaChecking.cpp') diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 9dd03133b99..ec36963ed61 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -4202,8 +4202,11 @@ static bool IsTailPaddedMemberArray(Sema &S, llvm::APInt Size, return false; const RecordDecl *RD = dyn_cast(FD->getDeclContext()); - if (!RD || !RD->isStruct()) - return false; + if (!RD) return false; + if (RD->isUnion()) return false; + if (const CXXRecordDecl *CRD = dyn_cast(RD)) { + if (!CRD->isStandardLayout()) return false; + } // See if this is the last field decl in the record. const Decl *D = FD; -- cgit v1.2.3