<br><br><div class="gmail_quote">On Sun, Sep 18, 2011 at 4:14 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard-llvm@metafoo.co.uk">richard-llvm@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Author: rsmith<br>
Date: Sun Sep 18 06:14:50 2011<br>
New Revision: 139996<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=139996&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=139996&view=rev</a><br>
Log:<br>
PR10954: variant members should not be implicitly initialized in constructors if no<br>
mem-initializer is specified for them, unless an in-class initializer is specified.<br>
<br>
Modified:<br>
cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
cfe/trunk/test/CXX/special/class.init/class.base.init/p8-0x.cpp<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=139996&r1=139995&r2=139996&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=139996&r1=139995&r2=139996&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Sep 18 06:14:50 2011<br>
@@ -2291,6 +2291,11 @@<br>
return false;<br>
}<br>
<br>
+ // Don't build an implicit initializer for union members if none was<br>
+ // explicitly specified.<br>
+ if (Field->getParent()->isUnion())<br>
+ return false;<br>
+<br>
// Don't try to build an implicit initializer if there were semantic<br>
// errors in any of the initializers (and therefore we might be<br>
// missing some that the user actually wrote).<br>
@@ -2464,17 +2469,6 @@<br>
continue;<br>
}<br>
<br>
- // If this field is somewhere within an anonymous union, we only<br>
- // initialize it if there's an explicit initializer.<br>
- if (isWithinAnonymousUnion(F)) {<br></blockquote><div><br></div><div>Seems this was the last/only use of isWithinAnonymousUnion & clang is warning about it being unused now:</div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace"> /home/dblaikie/Development/llvm/clean/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp:2338:13:warning: unused function 'isWithinAnonymousUnion'</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> [-Wunused-function]</font></div><div><font class="Apple-style-span" face="'courier new', monospace"> static bool isWithinAnonymousUnion(IndirectFieldDecl *F) {</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"> ^</font></div></div><div><br></div><div>Perhaps you could remove it?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
- if (CXXCtorInitializer *Init<br>
- = Info.AllBaseFields.lookup(F->getAnonField())) {<br>
- Info.AllToInit.push_back(Init);<br>
- }<br>
-<br>
- continue;<br>
- }<br>
-<br>
// Initialize each field of an anonymous struct individually.<br>
if (CollectFieldInitializer(*this, Info, F->getAnonField(), F))<br>
HadError = true;<br></blockquote></div>