summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp16
1 files changed, 5 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 0f7af4e30dd..b408f7f0882 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -2291,6 +2291,11 @@ static bool CollectFieldInitializer(Sema &SemaRef, BaseAndFieldInfo &Info,
return false;
}
+ // Don't build an implicit initializer for union members if none was
+ // explicitly specified.
+ if (Field->getParent()->isUnion())
+ return false;
+
// Don't try to build an implicit initializer if there were semantic
// errors in any of the initializers (and therefore we might be
// missing some that the user actually wrote).
@@ -2464,17 +2469,6 @@ bool Sema::SetCtorInitializers(CXXConstructorDecl *Constructor,
continue;
}
- // If this field is somewhere within an anonymous union, we only
- // initialize it if there's an explicit initializer.
- if (isWithinAnonymousUnion(F)) {
- if (CXXCtorInitializer *Init
- = Info.AllBaseFields.lookup(F->getAnonField())) {
- Info.AllToInit.push_back(Init);
- }
-
- continue;
- }
-
// Initialize each field of an anonymous struct individually.
if (CollectFieldInitializer(*this, Info, F->getAnonField(), F))
HadError = true;
OpenPOWER on IntegriCloud