git: 189b62e0bd77 - stable/12 - Reapply r349876:

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Wed, 22 Dec 2021 10:05:39 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=189b62e0bd775932e370dbfaf42ddd50745c2edb

commit 189b62e0bd775932e370dbfaf42ddd50745c2edb
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2020-08-06 16:42:48 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-22 09:58:19 +0000

    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>
    
    (cherry picked from commit ebc1d79affdadba662786fd002e4f6663fd95ccc)
---
 .../clang/include/clang/AST/DeclBase.h             | 46 +++++++--------
 .../llvm-project/clang/include/clang/AST/Type.h    | 68 +++++++++++-----------
 2 files changed, 57 insertions(+), 57 deletions(-)

diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h
index 4f33ff104ffd..af5959c4e9c2 100644
--- a/contrib/llvm-project/clang/include/clang/AST/DeclBase.h
+++ b/contrib/llvm-project/clang/include/clang/AST/DeclBase.h
@@ -1760,31 +1760,31 @@ protected:
     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;
diff --git a/contrib/llvm-project/clang/include/clang/AST/Type.h b/contrib/llvm-project/clang/include/clang/AST/Type.h
index 0fc50e0e799f..736f08651c84 100644
--- a/contrib/llvm-project/clang/include/clang/AST/Type.h
+++ b/contrib/llvm-project/clang/include/clang/AST/Type.h
@@ -1803,42 +1803,42 @@ protected:
     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;