[flang-commits] [flang] [flang] Add [[maybe_unused]] to fix -Werror build (PR #83456)

Peter Klausler via flang-commits flang-commits at lists.llvm.org
Thu Feb 29 10:17:07 PST 2024


https://github.com/klausler created https://github.com/llvm/llvm-project/pull/83456

Add the [[maybe_unused]] attribute to a variable in lib/Lower/OpenMP/OpenMP.cpp to avoid a (possibly bogus) unused variable warning when building with GCC 9.3.0.

>From 5da9e12de3b183055ebcb6a0acf0e4da76f8d177 Mon Sep 17 00:00:00 2001
From: Peter Klausler <pklausler at nvidia.com>
Date: Thu, 29 Feb 2024 10:14:45 -0800
Subject: [PATCH] [flang] Add [[maybe_unused]] to fix -Werror build

Add the [[maybe_unused]] attribute to a variable in lib/Lower/OpenMP/OpenMP.cpp
to avoid a (possibly bogus) unused variable warning when building with
GCC 9.3.0.
---
 flang/lib/Lower/OpenMP/OpenMP.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 21ad51c53d8742..b68976a4c765c3 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -840,7 +840,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
   llvm::SmallVector<mlir::Attribute> dependTypeOperands;
 
   Fortran::parser::OmpIfClause::DirectiveNameModifier directiveName;
-  llvm::omp::Directive directive;
+  [[maybe_unused]] llvm::omp::Directive directive;
   if constexpr (std::is_same_v<OpTy, mlir::omp::EnterDataOp>) {
     directiveName =
         Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetEnterData;



More information about the flang-commits mailing list