[clang] 881df55 - [clang] Fix -Wunused-variable in SemaChecking.cpp (NFC)

Jie Fu via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 8 01:04:29 PST 2024


Author: Jie Fu
Date: 2024-03-08T17:03:51+08:00
New Revision: 881df557501d339c7a14b16d68e43da5c732b424

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

LOG: [clang] Fix -Wunused-variable in SemaChecking.cpp (NFC)

llvm-project/clang/lib/Sema/SemaChecking.cpp:19192:15:
error: unused variable 'Field1Parent' [-Werror,-Wunused-variable]
  const Type *Field1Parent = Field1->getParent()->getTypeForDecl();
              ^
llvm-project/clang/lib/Sema/SemaChecking.cpp:19193:15:
error: unused variable 'Field2Parent' [-Werror,-Wunused-variable]
  const Type *Field2Parent = Field2->getParent()->getTypeForDecl();
              ^
2 errors generated.

Added: 
    

Modified: 
    clang/lib/Sema/SemaChecking.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index b34b8df0020137..a5f42b630c3fa2 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -19189,8 +19189,10 @@ static bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {
 static bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1,
                                FieldDecl *Field2,
                                bool AreUnionMembers = false) {
-  const Type *Field1Parent = Field1->getParent()->getTypeForDecl();
-  const Type *Field2Parent = Field2->getParent()->getTypeForDecl();
+  [[maybe_unused]] const Type *Field1Parent =
+      Field1->getParent()->getTypeForDecl();
+  [[maybe_unused]] const Type *Field2Parent =
+      Field2->getParent()->getTypeForDecl();
   assert(((Field1Parent->isStructureOrClassType() &&
            Field2Parent->isStructureOrClassType()) ||
           (Field1Parent->isUnionType() && Field2Parent->isUnionType())) &&


        


More information about the cfe-commits mailing list