[cfe-commits] r139996 - in /cfe/trunk: lib/Sema/SemaDeclCXX.cpp test/CXX/special/class.init/class.base.init/p8-0x.cpp

David Blaikie dblaikie at gmail.com
Sun Sep 18 18:09:53 PDT 2011


On Sun, Sep 18, 2011 at 4:14 AM, Richard Smith
<richard-llvm at metafoo.co.uk>wrote:

> Author: rsmith
> Date: Sun Sep 18 06:14:50 2011
> New Revision: 139996
>
> URL: http://llvm.org/viewvc/llvm-project?rev=139996&view=rev
> Log:
> PR10954: variant members should not be implicitly initialized in
> constructors if no
> mem-initializer is specified for them, unless an in-class initializer is
> specified.
>
> Modified:
>    cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>    cfe/trunk/test/CXX/special/class.init/class.base.init/p8-0x.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=139996&r1=139995&r2=139996&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Sun Sep 18 06:14:50 2011
> @@ -2291,6 +2291,11 @@
>     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 @@
>         continue;
>       }
>
> -      // If this field is somewhere within an anonymous union, we only
> -      // initialize it if there's an explicit initializer.
> -      if (isWithinAnonymousUnion(F)) {
>

Seems this was the last/only use of isWithinAnonymousUnion & clang is
warning about it being unused now:


/home/dblaikie/Development/llvm/clean/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp:2338:13:warning:
unused function 'isWithinAnonymousUnion'
          [-Wunused-function]
    static bool isWithinAnonymousUnion(IndirectFieldDecl *F) {
                ^

Perhaps you could remove it?



> -        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;
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110918/ea0609ab/attachment.html>


More information about the cfe-commits mailing list