https://github.com/andykaylor created 
https://github.com/llvm/llvm-project/pull/163997

This fixes a build failure that occurs with some versions of clang. There was a 
problem in clang, which has been fixed in more recent versions, where mixing 
GNU-style attributes with C++-style attributes caused a failure. A recent code 
change updated a few uses of `LLVM_ATTRIBUTE_UNUSED` to `[[maybe_unused]]`, 
triggering this problem.

This change reorders the attributes in a way that avoids the issue.

>From f25ceba4f22b3445e3fe6ab99978008cffa5a048 Mon Sep 17 00:00:00 2001
From: Andy Kaylor <[email protected]>
Date: Fri, 17 Oct 2025 10:30:39 -0700
Subject: [PATCH] [CIR][NFC] Fix maybe_unused build issues

This fixes a build failure that occurs with some versions of clang. There
was a problem in clang, which has been fixed in more recent versions, where
mixing GNU-style attributes with C++-style attributes caused a failure.
A recent code change updated a few uses of `LLVM_ATTRIBUTE_UNUSED` to
`[[maybe_unused]]`, triggering this problem.

This change reorders the attributes in a way that avoids the issue.
---
 clang/lib/CIR/CodeGen/CIRGenValue.h | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CIR/CodeGen/CIRGenValue.h 
b/clang/lib/CIR/CodeGen/CIRGenValue.h
index 08d9913c09c38..d8fac76a0bd03 100644
--- a/clang/lib/CIR/CodeGen/CIRGenValue.h
+++ b/clang/lib/CIR/CodeGen/CIRGenValue.h
@@ -307,8 +307,9 @@ class AggValueSlot {
   /// This is set to true if some external code is responsible for setting up a
   /// destructor for the slot.  Otherwise the code which constructs it should
   /// push the appropriate cleanup.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned destructedFlag : 1;
+  unsigned destructedFlag : 1;
 
   /// This is set to true if the memory in the slot is known to be zero before
   /// the assignment into it.  This means that zero fields don't need to be 
set.
@@ -326,16 +327,18 @@ class AggValueSlot {
   /// over.  Since it's invalid in general to memcpy a non-POD C++
   /// object, it's important that this flag never be set when
   /// evaluating an expression which constructs such an object.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned aliasedFlag : 1;
+  unsigned aliasedFlag : 1;
 
   /// This is set to true if the tail padding of this slot might overlap
   /// another object that may have already been initialized (and whose
   /// value must be preserved by this initialization). If so, we may only
   /// store up to the dsize of the type. Otherwise we can widen stores to
   /// the size of the type.
+  [[maybe_unused]] 
   LLVM_PREFERRED_TYPE(bool)
-  [[maybe_unused]] unsigned overlapFlag : 1;
+  unsigned overlapFlag : 1;
 
 public:
   enum IsDestructed_t { IsNotDestructed, IsDestructed };

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to