summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2017-02-23 22:41:47 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2017-02-23 22:41:47 +0000
commit382bc51fddbfb010b2e068bbdf94ab99811b2768 (patch)
treea3e11869468d7db13f7c46708c3a9d85f26b8bb9 /clang/lib
parent620db1f3dd08ebbba71b0e16f83c11323e04bc05 (diff)
downloadbcm5719-llvm-382bc51fddbfb010b2e068bbdf94ab99811b2768.tar.gz
bcm5719-llvm-382bc51fddbfb010b2e068bbdf94ab99811b2768.zip
PR32044: Fix some cases where we would confuse a transparent init-list expression with an aggregate init.
llvm-svn: 296033
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Expr.cpp5
-rw-r--r--clang/lib/Sema/SemaInit.cpp5
2 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 366e5bf404f..c22661758c8 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1882,6 +1882,11 @@ bool InitListExpr::isTransparent() const {
if (getNumInits() != 1 || !getInit(0))
return false;
+ // Don't confuse aggregate initialization of a struct X { X &x; }; with a
+ // transparent struct copy.
+ if (!getInit(0)->isRValue() && getType()->isRecordType())
+ return false;
+
return getType().getCanonicalType() ==
getInit(0)->getType().getCanonicalType();
}
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b8fee85516e..3970e831c5c 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -623,6 +623,11 @@ InitListChecker::FillInEmptyInitializations(const InitializedEntity &Entity,
assert((ILE->getType() != SemaRef.Context.VoidTy) &&
"Should not have void type");
+ // A transparent ILE is not performing aggregate initialization and should
+ // not be filled in.
+ if (ILE->isTransparent())
+ return;
+
if (const RecordType *RType = ILE->getType()->getAs<RecordType>()) {
const RecordDecl *RDecl = RType->getDecl();
if (RDecl->isUnion() && ILE->getInitializedFieldInUnion())
OpenPOWER on IntegriCloud