Reapply r349876:

Apply a workaround to be able to build clang 8.0.0 headers with clang
3.4.1, which is still in the stable/10 branch.

It looks like clang 3.4.1 implements static_asserts by instantiating a
temporary static object, and if those are in an anonymous union, it
results in "error: anonymous union can only contain non-static data
members".

To work around this implementation limitation, move the static_asserts
in question out of the anonymous unions.

This should make building the latest stable/11 from stable/10 possible
again.

Reported by:	Mike Tancsa <mike@sentex.net>
This commit is contained in:
Dimitry Andric 2020-08-06 16:42:48 +00:00
parent 4beee10792
commit ebc1d79aff
2 changed files with 57 additions and 57 deletions

View File

@ -1760,31 +1760,31 @@ class DeclContext {
ObjCContainerDeclBitfields ObjCContainerDeclBits;
LinkageSpecDeclBitfields LinkageSpecDeclBits;
BlockDeclBitfields BlockDeclBits;
static_assert(sizeof(DeclContextBitfields) <= 8,
"DeclContextBitfields is larger than 8 bytes!");
static_assert(sizeof(TagDeclBitfields) <= 8,
"TagDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(EnumDeclBitfields) <= 8,
"EnumDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(RecordDeclBitfields) <= 8,
"RecordDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8,
"OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionDeclBitfields) <= 8,
"FunctionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(CXXConstructorDeclBitfields) <= 8,
"CXXConstructorDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
"ObjCMethodDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCContainerDeclBitfields) <= 8,
"ObjCContainerDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(LinkageSpecDeclBitfields) <= 8,
"LinkageSpecDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(BlockDeclBitfields) <= 8,
"BlockDeclBitfields is larger than 8 bytes!");
};
static_assert(sizeof(DeclContextBitfields) <= 8,
"DeclContextBitfields is larger than 8 bytes!");
static_assert(sizeof(TagDeclBitfields) <= 8,
"TagDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(EnumDeclBitfields) <= 8,
"EnumDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(RecordDeclBitfields) <= 8,
"RecordDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(OMPDeclareReductionDeclBitfields) <= 8,
"OMPDeclareReductionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionDeclBitfields) <= 8,
"FunctionDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(CXXConstructorDeclBitfields) <= 8,
"CXXConstructorDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCMethodDeclBitfields) <= 8,
"ObjCMethodDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCContainerDeclBitfields) <= 8,
"ObjCContainerDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(LinkageSpecDeclBitfields) <= 8,
"LinkageSpecDeclBitfields is larger than 8 bytes!");
static_assert(sizeof(BlockDeclBitfields) <= 8,
"BlockDeclBitfields is larger than 8 bytes!");
/// FirstDecl - The first declaration stored within this declaration
/// context.
mutable Decl *FirstDecl = nullptr;

View File

@ -1803,42 +1803,42 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
DependentTemplateSpecializationTypeBitfields
DependentTemplateSpecializationTypeBits;
PackExpansionTypeBitfields PackExpansionTypeBits;
static_assert(sizeof(TypeBitfields) <= 8,
"TypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ArrayTypeBitfields) <= 8,
"ArrayTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AttributedTypeBitfields) <= 8,
"AttributedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AutoTypeBitfields) <= 8,
"AutoTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(BuiltinTypeBitfields) <= 8,
"BuiltinTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionTypeBitfields) <= 8,
"FunctionTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCObjectTypeBitfields) <= 8,
"ObjCObjectTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ReferenceTypeBitfields) <= 8,
"ReferenceTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(TypeWithKeywordBitfields) <= 8,
"TypeWithKeywordBitfields is larger than 8 bytes!");
static_assert(sizeof(ElaboratedTypeBitfields) <= 8,
"ElaboratedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(VectorTypeBitfields) <= 8,
"VectorTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(SubstTemplateTypeParmPackTypeBitfields) <= 8,
"SubstTemplateTypeParmPackTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
"TemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(DependentTemplateSpecializationTypeBitfields) <= 8,
"DependentTemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
"PackExpansionTypeBitfields is larger than 8 bytes");
};
static_assert(sizeof(TypeBitfields) <= 8,
"TypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ArrayTypeBitfields) <= 8,
"ArrayTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AttributedTypeBitfields) <= 8,
"AttributedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(AutoTypeBitfields) <= 8,
"AutoTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(BuiltinTypeBitfields) <= 8,
"BuiltinTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(FunctionTypeBitfields) <= 8,
"FunctionTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ObjCObjectTypeBitfields) <= 8,
"ObjCObjectTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(ReferenceTypeBitfields) <= 8,
"ReferenceTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(TypeWithKeywordBitfields) <= 8,
"TypeWithKeywordBitfields is larger than 8 bytes!");
static_assert(sizeof(ElaboratedTypeBitfields) <= 8,
"ElaboratedTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(VectorTypeBitfields) <= 8,
"VectorTypeBitfields is larger than 8 bytes!");
static_assert(sizeof(SubstTemplateTypeParmPackTypeBitfields) <= 8,
"SubstTemplateTypeParmPackTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(TemplateSpecializationTypeBitfields) <= 8,
"TemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(DependentTemplateSpecializationTypeBitfields) <= 8,
"DependentTemplateSpecializationTypeBitfields is larger"
" than 8 bytes!");
static_assert(sizeof(PackExpansionTypeBitfields) <= 8,
"PackExpansionTypeBitfields is larger than 8 bytes");
private:
template <class T> friend class TypePropertyCache;