From feb1ede96412edd2e392314badde8308a6588920 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 15 Mar 2013 00:32:52 +0000 Subject: [PATCH] Silence anonymous type in anonymous union warnings. llvm-svn: 177133 --- clang/include/clang/AST/DeclTemplate.h | 17 ++++--- clang/include/clang/AST/DeclarationName.h | 53 ++++++++++---------- clang/include/clang/AST/DependentDiagnostic.h | 18 +++---- clang/include/clang/AST/Expr.h | 23 +++++---- clang/include/clang/AST/TemplateBase.h | 71 +++++++++++++++------------ clang/include/clang/AST/TemplateName.h | 19 +++---- clang/include/clang/Sema/DeclSpec.h | 28 ++++++----- clang/include/clang/Sema/DelayedDiagnostic.h | 32 ++++++------ clang/include/clang/Sema/Initialization.h | 60 ++++++++++++---------- 9 files changed, 173 insertions(+), 148 deletions(-) diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 525a156..425a617 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -458,18 +458,19 @@ public: /// }; /// \endcode class DependentFunctionTemplateSpecializationInfo { + struct CA { + /// The number of potential template candidates. + unsigned NumTemplates; + + /// The number of template arguments. + unsigned NumArgs; + }; + union { // Force sizeof to be a multiple of sizeof(void*) so that the // trailing data is aligned. void *Aligner; - - struct { - /// The number of potential template candidates. - unsigned NumTemplates; - - /// The number of template arguments. - unsigned NumArgs; - } d; + struct CA d; }; /// The locations of the left and right angle brackets. diff --git a/clang/include/clang/AST/DeclarationName.h b/clang/include/clang/AST/DeclarationName.h index d302db4..f28882b 100644 --- a/clang/include/clang/AST/DeclarationName.h +++ b/clang/include/clang/AST/DeclarationName.h @@ -382,32 +382,35 @@ public: /// for a declaration name. Needs a DeclarationName in order /// to be interpreted correctly. struct DeclarationNameLoc { + // The source location for identifier stored elsewhere. + // struct {} Identifier; + + // Type info for constructors, destructors and conversion functions. + // Locations (if any) for the tilde (destructor) or operator keyword + // (conversion) are stored elsewhere. + struct NT { + TypeSourceInfo* TInfo; + }; + + // The location (if any) of the operator keyword is stored elsewhere. + struct CXXOpName { + unsigned BeginOpNameLoc; + unsigned EndOpNameLoc; + }; + + // The location (if any) of the operator keyword is stored elsewhere. + struct CXXLitOpName { + unsigned OpNameLoc; + }; + + // struct {} CXXUsingDirective; + // struct {} ObjCZeroArgSelector; + // struct {} ObjCOneArgSelector; + // struct {} ObjCMultiArgSelector; union { - // The source location for identifier stored elsewhere. - // struct {} Identifier; - - // Type info for constructors, destructors and conversion functions. - // Locations (if any) for the tilde (destructor) or operator keyword - // (conversion) are stored elsewhere. - struct { - TypeSourceInfo* TInfo; - } NamedType; - - // The location (if any) of the operator keyword is stored elsewhere. - struct { - unsigned BeginOpNameLoc; - unsigned EndOpNameLoc; - } CXXOperatorName; - - // The location (if any) of the operator keyword is stored elsewhere. - struct { - unsigned OpNameLoc; - } CXXLiteralOperatorName; - - // struct {} CXXUsingDirective; - // struct {} ObjCZeroArgSelector; - // struct {} ObjCOneArgSelector; - // struct {} ObjCMultiArgSelector; + struct NT NamedType; + struct CXXOpName CXXOperatorName; + struct CXXLitOpName CXXLiteralOperatorName; }; DeclarationNameLoc(DeclarationName Name); diff --git a/clang/include/clang/AST/DependentDiagnostic.h b/clang/include/clang/AST/DependentDiagnostic.h index cb556ef..004b45d 100644 --- a/clang/include/clang/AST/DependentDiagnostic.h +++ b/clang/include/clang/AST/DependentDiagnostic.h @@ -108,16 +108,14 @@ private: PartialDiagnostic Diag; - union { - struct { - unsigned Loc; - unsigned Access : 2; - unsigned IsMember : 1; - NamedDecl *TargetDecl; - CXXRecordDecl *NamingClass; - void *BaseObjectType; - } AccessData; - }; + struct { + unsigned Loc; + unsigned Access : 2; + unsigned IsMember : 1; + NamedDecl *TargetDecl; + CXXRecordDecl *NamingClass; + void *BaseObjectType; + } AccessData; }; /// diff --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h index 9c5ea56..91804f0 100644 --- a/clang/include/clang/AST/Expr.h +++ b/clang/include/clang/AST/Expr.h @@ -60,18 +60,21 @@ struct SubobjectAdjustment { MemberPointerAdjustment } Kind; - union { - struct { - const CastExpr *BasePath; - const CXXRecordDecl *DerivedClass; - } DerivedToBase; - FieldDecl *Field; + struct DTB { + const CastExpr *BasePath; + const CXXRecordDecl *DerivedClass; + }; + + struct P { + const MemberPointerType *MPT; + Expr *RHS; + }; - struct { - const MemberPointerType *MPT; - Expr *RHS; - } Ptr; + union { + struct DTB DerivedToBase; + FieldDecl *Field; + struct P Ptr; }; SubobjectAdjustment(const CastExpr *BasePath, diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index 1e22de7..70b934f 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@ -72,32 +72,36 @@ private: /// \brief The kind of template argument we're storing. unsigned Kind; + struct DA { + ValueDecl *D; + bool ForRefParam; + }; + struct I { + // We store a decomposed APSInt with the data allocated by ASTContext if + // BitWidth > 64. The memory may be shared between multiple + // TemplateArgument instances. + union { + uint64_t VAL; ///< Used to store the <= 64 bits integer value. + const uint64_t *pVal; ///< Used to store the >64 bits integer value. + }; + unsigned BitWidth : 31; + unsigned IsUnsigned : 1; + void *Type; + }; + struct A { + const TemplateArgument *Args; + unsigned NumArgs; + }; + struct TA { + void *Name; + unsigned NumExpansions; + }; union { + struct DA DeclArg; + struct I Integer; + struct A Args; + struct TA TemplateArg; uintptr_t TypeOrValue; - struct { - ValueDecl *D; - bool ForRefParam; - } DeclArg; - struct { - // We store a decomposed APSInt with the data allocated by ASTContext if - // BitWidth > 64. The memory may be shared between multiple - // TemplateArgument instances. - union { - uint64_t VAL; ///< Used to store the <= 64 bits integer value. - const uint64_t *pVal; ///< Used to store the >64 bits integer value. - }; - unsigned BitWidth : 31; - unsigned IsUnsigned : 1; - void *Type; - } Integer; - struct { - const TemplateArgument *Args; - unsigned NumArgs; - } Args; - struct { - void *Name; - unsigned NumExpansions; - } TemplateArg; }; TemplateArgument(TemplateName, bool) LLVM_DELETED_FUNCTION; @@ -341,17 +345,20 @@ public: /// Location information for a TemplateArgument. struct TemplateArgumentLocInfo { private: + + struct T { + // FIXME: We'd like to just use the qualifier in the TemplateName, + // but template arguments get canonicalized too quickly. + NestedNameSpecifier *Qualifier; + void *QualifierLocData; + unsigned TemplateNameLoc; + unsigned EllipsisLoc; + }; + union { + struct T Template; Expr *Expression; TypeSourceInfo *Declarator; - struct { - // FIXME: We'd like to just use the qualifier in the TemplateName, - // but template arguments get canonicalized too quickly. - NestedNameSpecifier *Qualifier; - void *QualifierLocData; - unsigned TemplateNameLoc; - unsigned EllipsisLoc; - } Template; }; public: diff --git a/clang/include/clang/AST/TemplateName.h b/clang/include/clang/AST/TemplateName.h index 174b451..0b9d4c8 100644 --- a/clang/include/clang/AST/TemplateName.h +++ b/clang/include/clang/AST/TemplateName.h @@ -46,16 +46,17 @@ protected: SubstTemplateTemplateParmPack }; - union { - struct { - /// \brief A Kind. - unsigned Kind : 2; - - /// \brief The number of stored templates or template arguments, - /// depending on which subclass we have. - unsigned Size : 30; - } Bits; + struct BitsTag { + /// \brief A Kind. + unsigned Kind : 2; + /// \brief The number of stored templates or template arguments, + /// depending on which subclass we have. + unsigned Size : 30; + }; + + union { + struct BitsTag Bits; void *PointerAlignment; }; diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h index 4f87e9d..0c73421 100644 --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -821,6 +821,20 @@ public: IK_ImplicitSelfParam } Kind; + struct OFI { + /// \brief The kind of overloaded operator. + OverloadedOperatorKind Operator; + + /// \brief The source locations of the individual tokens that name + /// the operator, e.g., the "new", "[", and "]" tokens in + /// operator new []. + /// + /// Different operators have different numbers of tokens in their name, + /// up to three. Any remaining source locations in this array will be + /// set to an invalid value for operators with fewer than three tokens. + unsigned SymbolLocations[3]; + }; + /// \brief Anonymous union that holds extra data associated with the /// parsed unqualified-id. union { @@ -830,19 +844,7 @@ public: /// \brief When Kind == IK_OperatorFunctionId, the overloaded operator /// that we parsed. - struct { - /// \brief The kind of overloaded operator. - OverloadedOperatorKind Operator; - - /// \brief The source locations of the individual tokens that name - /// the operator, e.g., the "new", "[", and "]" tokens in - /// operator new []. - /// - /// Different operators have different numbers of tokens in their name, - /// up to three. Any remaining source locations in this array will be - /// set to an invalid value for operators with fewer than three tokens. - unsigned SymbolLocations[3]; - } OperatorFunctionId; + struct OFI OperatorFunctionId; /// \brief When Kind == IK_ConversionFunctionId, the type that the /// conversion function names. diff --git a/clang/include/clang/Sema/DelayedDiagnostic.h b/clang/include/clang/Sema/DelayedDiagnostic.h index 77cacfb..3704e09 100644 --- a/clang/include/clang/Sema/DelayedDiagnostic.h +++ b/clang/include/clang/Sema/DelayedDiagnostic.h @@ -199,21 +199,25 @@ public: } private: + + struct DD { + const NamedDecl *Decl; + const ObjCInterfaceDecl *UnknownObjCClass; + const ObjCPropertyDecl *ObjCProperty; + const char *Message; + size_t MessageLen; + }; + + struct FTD { + unsigned Diagnostic; + unsigned Argument; + void *OperandType; + }; + union { - /// Deprecation. - struct { - const NamedDecl *Decl; - const ObjCInterfaceDecl *UnknownObjCClass; - const ObjCPropertyDecl *ObjCProperty; - const char *Message; - size_t MessageLen; - } DeprecationData; - - struct { - unsigned Diagnostic; - unsigned Argument; - void *OperandType; - } ForbiddenTypeData; + /// Deprecation + struct DD DeprecationData; + struct FTD ForbiddenTypeData; /// Access control. char AccessData[sizeof(AccessedEntity)]; diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h index e177374..8459be1 100644 --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -88,7 +88,27 @@ private: /// \brief The type of the object or reference being initialized. QualType Type; - + + struct LN { + /// \brief When Kind == EK_Result, EK_Exception, EK_New, the + /// location of the 'return', 'throw', or 'new' keyword, + /// respectively. When Kind == EK_Temporary, the location where + /// the temporary is being created. + unsigned Location; + + /// \brief Whether the entity being initialized may end up using the + /// named return value optimization (NRVO). + bool NRVO; + }; + + struct C { + /// \brief The variable being captured by an EK_LambdaCapture. + VarDecl *Var; + + /// \brief The source location at which the capture occurs. + unsigned Location; + }; + union { /// \brief When Kind == EK_Variable, or EK_Member, the VarDecl or /// FieldDecl, respectively. @@ -101,18 +121,8 @@ private: /// \brief When Kind == EK_Temporary, the type source information for /// the temporary. TypeSourceInfo *TypeInfo; - - struct { - /// \brief When Kind == EK_Result, EK_Exception, EK_New, the - /// location of the 'return', 'throw', or 'new' keyword, - /// respectively. When Kind == EK_Temporary, the location where - /// the temporary is being created. - unsigned Location; - - /// \brief Whether the entity being initialized may end up using the - /// named return value optimization (NRVO). - bool NRVO; - } LocAndNRVO; + + struct LN LocAndNRVO; /// \brief When Kind == EK_Base, the base specifier that provides the /// base class. The lower bit specifies whether the base is an inherited @@ -123,14 +133,8 @@ private: /// EK_ComplexElement, the index of the array or vector element being /// initialized. unsigned Index; - - struct { - /// \brief The variable being captured by an EK_LambdaCapture. - VarDecl *Var; - - /// \brief The source location at which the capture occurs. - unsigned Location; - } Capture; + + struct C Capture; }; InitializedEntity() { } @@ -639,7 +643,13 @@ public: // \brief The type that results from this initialization. QualType Type; - + + struct F { + bool HadMultipleCandidates; + FunctionDecl *Function; + DeclAccessPair FoundDecl; + }; + union { /// \brief When Kind == SK_ResolvedOverloadedFunction or Kind == /// SK_UserConversion, the function that the expression should be @@ -651,11 +661,7 @@ public: /// selected from an overloaded set having size greater than 1. /// For conversion decls, the naming class is the source type. /// For construct decls, the naming class is the target type. - struct { - bool HadMultipleCandidates; - FunctionDecl *Function; - DeclAccessPair FoundDecl; - } Function; + struct F Function; /// \brief When Kind = SK_ConversionSequence, the implicit conversion /// sequence. -- 2.7.4