[PS5] Ignore 'packed' on one-byte bitfields, matching PS4
authorPaul Robinson <paul.robinson@sony.com>
Thu, 2 Jun 2022 21:40:52 +0000 (14:40 -0700)
committerPaul Robinson <paul.robinson@sony.com>
Thu, 2 Jun 2022 21:41:18 +0000 (14:41 -0700)
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Sema/struct-packed-align.c

index 466ca1b..b629fcb 100644 (file)
@@ -1404,9 +1404,9 @@ static void handlePackedAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
                                 FD->isBitField() &&
                                 S.Context.getTypeAlign(FD->getType()) <= 8);
 
-    if (S.getASTContext().getTargetInfo().getTriple().isPS4()) {
+    if (S.getASTContext().getTargetInfo().getTriple().isPS()) {
       if (BitfieldByteAligned)
-        // The PS4 target needs to maintain ABI backwards compatibility.
+        // The PS4/PS5 targets need to maintain ABI backwards compatibility.
         S.Diag(AL.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
             << AL << FD->getType();
       else
index 03b012e..2a60f36 100644 (file)
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify
 // RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-windows-coff -verify
 // RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-scei-ps4 -verify
+// RUN: %clang_cc1 %s -fsyntax-only -triple=x86_64-sie-ps5 -verify
 
 // Packed structs.
 struct s {
@@ -147,9 +148,9 @@ extern int n2[__alignof(struct nS) == 1 ? 1 : -1];
 // See the documentation of -Wpacked-bitfield-compat for more information.
 struct packed_chars {
   char a : 8, b : 8, c : 8, d : 4;
-#ifdef __ORBIS__
-  // Test for pre-r254596 clang behavior on the PS4 target. PS4 must maintain
-  // ABI backwards compatibility.
+#ifdef __SCE__
+  // Test for pre-r254596 clang behavior on the PS4/PS5 targets, which must
+  // maintain ABI backwards compatibility.
   char e : 8 __attribute__((packed));
   // expected-warning@-1 {{'packed' attribute ignored for field of type 'char'}}
 #else
@@ -159,11 +160,11 @@ struct packed_chars {
   char f : 4, g : 8, h : 8, i : 8;
 };
 
-#if (defined(_WIN32) || defined(__ORBIS__)) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
+#if (defined(_WIN32) || defined(__SCE__)) && !defined(__declspec) // _MSC_VER is unavailable in cc1.
 // On Windows clang uses MSVC compatible layout in this case.
 //
-// Additionally, test for pre-r254596 clang behavior on the PS4 target. PS4
-// must maintain ABI backwards compatibility.
+// Additionally, test for pre-r254596 clang behavior on the PS4/PS5 targets.
+// They must maintain ABI backwards compatibility.
 extern int o1[sizeof(struct packed_chars) == 9 ? 1 : -1];
 extern int o2[__alignof(struct packed_chars) == 1 ? 1 : -1];
 #elif defined(_AIX)