summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
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