summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-05-30 09:12:07 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-05-30 09:12:07 +0000
commit4e51dfc4312897987417b59839684e4ffd3201f6 (patch)
tree8227cf066e05c8b6173a36872b95fc490145ac57 /clang/lib/CodeGen/CGExprConstant.cpp
parent15864f1518c6b15b6936cd746227d61530f92427 (diff)
downloadbcm5719-llvm-4e51dfc4312897987417b59839684e4ffd3201f6.tar.gz
bcm5719-llvm-4e51dfc4312897987417b59839684e4ffd3201f6.zip
[CodeGen] Indirect fields can initialize a union
The first named data member is the field used to default initialize the union. An IndirectFieldDecl can introduce the first named data member of a union. llvm-svn: 238649
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 73ca0cc1c3d..b90b3ab61d8 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1349,8 +1349,14 @@ static llvm::Constant *EmitNullConstant(CodeGenModule &CGM,
}
// For unions, stop after the first named field.
- if (record->isUnion() && Field->getDeclName())
- break;
+ if (record->isUnion()) {
+ if (Field->getIdentifier())
+ break;
+ if (const auto *FieldRD =
+ dyn_cast_or_null<RecordDecl>(Field->getType()->getAsTagDecl()))
+ if (FieldRD->findFirstNamedDataMember())
+ break;
+ }
}
// Fill in the virtual bases, if we're working with the complete object.
OpenPOWER on IntegriCloud