[clang] ebd25fd - [clang] Fix Wnested-anon-types in ABIArgInfo

Raphael Isemann via cfe-commits cfe-commits at lists.llvm.org
Fri May 21 02:19:01 PDT 2021


Author: Raphael Isemann
Date: 2021-05-21T11:18:43+02:00
New Revision: ebd25fde5e04fa954f3fbad3fa0ee89f511a907a

URL: https://github.com/llvm/llvm-project/commit/ebd25fde5e04fa954f3fbad3fa0ee89f511a907a
DIFF: https://github.com/llvm/llvm-project/commit/ebd25fde5e04fa954f3fbad3fa0ee89f511a907a.diff

LOG: [clang] Fix Wnested-anon-types in ABIArgInfo

D98794 added the DirectAttr/IndirectAttr struct fields to that union, but
declaring anonymous structs in an anonymous union triggers `-Wnested-anon-types`
warnings. We can't just give them a name as they are in an anonymous union, so
this just declares the type outside.

```
clang/include/clang/CodeGen/CGFunctionInfo.h:97:5: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
    struct {
    ^
clang/include/clang/CodeGen/CGFunctionInfo.h:101:5: warning: anonymous types declared in an anonymous union are an extension [-Wnested-anon-types]
    struct {
    ^
```

Reviewed By: chill

Differential Revision: https://reviews.llvm.org/D102903

Added: 
    

Modified: 
    clang/include/clang/CodeGen/CGFunctionInfo.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/CodeGen/CGFunctionInfo.h b/clang/include/clang/CodeGen/CGFunctionInfo.h
index 91d867e7f64a5..4899c9deda6a3 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -93,15 +93,17 @@ class ABIArgInfo {
     llvm::Type *PaddingType; // canHavePaddingType()
     llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand()
   };
+  struct DirectAttrInfo {
+    unsigned Offset;
+    unsigned Align;
+  };
+  struct IndirectAttrInfo {
+    unsigned Align;
+    unsigned AddrSpace;
+  };
   union {
-    struct {
-      unsigned Offset;
-      unsigned Align;
-    } DirectAttr;              // isDirect() || isExtend()
-    struct {
-      unsigned Align;
-      unsigned AddrSpace;
-    } IndirectAttr;            // isIndirect()
+    DirectAttrInfo DirectAttr;     // isDirect() || isExtend()
+    IndirectAttrInfo IndirectAttr; // isIndirect()
     unsigned AllocaFieldIndex; // isInAlloca()
   };
   Kind TheKind;


        


More information about the cfe-commits mailing list