diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-09 21:35:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-09 21:35:13 +0000 |
commit | 8389eab190afef3462f6418b8d8fb70fb01c4005 (patch) | |
tree | d2a41484bacad7d91991fdd7902ea5e7a4ab0133 /lib | |
parent | aad6953ca1149d44cebadca8839745796bfd524e (diff) |
Fix PR2400 by more graceful handling of invalid decls. Don't try to layout
an invalid struct decl. Thanks to Martin Doucha for the
isIncompleteArrayType part of this patch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AST/ASTContext.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a20236f9eb..0325ba5734 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -325,6 +325,12 @@ ASTContext::getTypeInfo(QualType T) { break; } case Type::Tagged: { + if (cast<TagType>(T)->getDecl()->isInvalidDecl()) { + Width = 1; + Align = 1; + break; + } + if (EnumType *ET = dyn_cast<EnumType>(cast<TagType>(T))) return getTypeInfo(ET->getDecl()->getIntegerType()); @@ -377,8 +383,8 @@ void ASTRecordLayout::LayoutField(const FieldDecl *FD, unsigned FieldNo, if (!FD->getIdentifier()) FieldAlign = 1; } else { - if (FD->getType()->isIncompleteType()) { - // This must be a flexible array member; we can't directly + if (FD->getType()->isIncompleteArrayType()) { + // This is a flexible array member; we can't directly // query getTypeInfo about these, so we figure it out here. // Flexible array members don't have any size, but they // have to be aligned appropriately for their element type. |