summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2013-03-15 00:32:52 +0000
committerEric Christopher <echristo@gmail.com>2013-03-15 00:32:52 +0000
commite462c60ac3365d3302b7d0a566c5cb7dbe0e5ae3 (patch)
tree9a6ce9906920c5b818e967cf8d8c334996618369
parent96db329b3a982ac83c700c4469a3f618dc53cb42 (diff)
Silence anonymous type in anonymous union warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177133 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclTemplate.h17
-rw-r--r--include/clang/AST/DeclarationName.h53
-rw-r--r--include/clang/AST/DependentDiagnostic.h18
-rw-r--r--include/clang/AST/Expr.h23
-rw-r--r--include/clang/AST/TemplateBase.h71
-rw-r--r--include/clang/AST/TemplateName.h19
-rw-r--r--include/clang/Sema/DeclSpec.h28
-rw-r--r--include/clang/Sema/DelayedDiagnostic.h32
-rw-r--r--include/clang/Sema/Initialization.h60
9 files changed, 173 insertions, 148 deletions
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 525a156a93..425a617738 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/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/include/clang/AST/DeclarationName.h b/include/clang/AST/DeclarationName.h
index d302db48b3..f28882b3bf 100644
--- a/include/clang/AST/DeclarationName.h
+++ b/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/include/clang/AST/DependentDiagnostic.h b/include/clang/AST/DependentDiagnostic.h
index cb556ef1eb..004b45da0f 100644
--- a/include/clang/AST/DependentDiagnostic.h
+++ b/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/include/clang/AST/Expr.h b/include/clang/AST/Expr.h
index 9c5ea56f5e..91804f01eb 100644
--- a/include/clang/AST/Expr.h
+++ b/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/include/clang/AST/TemplateBase.h b/include/clang/AST/TemplateBase.h
index 1e22de76f3..70b934f36c 100644
--- a/include/clang/AST/TemplateBase.h
+++ b/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/include/clang/AST/TemplateName.h b/include/clang/AST/TemplateName.h
index 174b451b2b..0b9d4c8547 100644
--- a/include/clang/AST/TemplateName.h
+++ b/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/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h
index 4f87e9dd75..0c734216b1 100644
--- a/include/clang/Sema/DeclSpec.h
+++ b/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/include/clang/Sema/DelayedDiagnostic.h b/include/clang/Sema/DelayedDiagnostic.h
index 77cacfbdeb..3704e095c7 100644
--- a/include/clang/Sema/DelayedDiagnostic.h
+++ b/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/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h
index e1773748dc..8459be16f4 100644
--- a/include/clang/Sema/Initialization.h
+++ b/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.