summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2016-10-06 09:47:29 +0000
committerAlex Lorenz <arphaman@gmail.com>2016-10-06 09:47:29 +0000
commit6f4bc4f68db54bab350c87e0374e370dfc15442b (patch)
tree8dc60a905d955e49ca9b71816f39391c77f54581 /clang/lib/Sema/SemaDeclAttr.cpp
parent898375994b4d810934339e21e075dfcd6e15c728 (diff)
downloadbcm5719-llvm-6f4bc4f68db54bab350c87e0374e370dfc15442b.tar.gz
bcm5719-llvm-6f4bc4f68db54bab350c87e0374e370dfc15442b.zip
[Sema] Fix PR30520: Handle incomplete field types in transparent_union unions
This commit fixes a crash that happens when clang is analyzing a transparent_union attribute on a union which has a field with incomplete type. rdar://28630028 Differential Revision: https://reviews.llvm.org/D25273 llvm-svn: 283432
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index e06f110f0e4..3e8a39a5786 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3044,10 +3044,14 @@ static void handleTransparentUnionAttr(Sema &S, Decl *D,
return;
}
+ if (FirstType->isIncompleteType())
+ return;
uint64_t FirstSize = S.Context.getTypeSize(FirstType);
uint64_t FirstAlign = S.Context.getTypeAlign(FirstType);
for (; Field != FieldEnd; ++Field) {
QualType FieldType = Field->getType();
+ if (FieldType->isIncompleteType())
+ return;
// FIXME: this isn't fully correct; we also need to test whether the
// members of the union would all have the same calling convention as the
// first member of the union. Checking just the size and alignment isn't
OpenPOWER on IntegriCloud