[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 11:15:47 PST 2024


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

>From 1f5e9f84d1312973e18125319248b2029924c0e6 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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp
index 21ad51c53d8742..90fc1f80f57ab7 100644
--- a/flang/lib/Lower/OpenMP/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP/OpenMP.cpp
@@ -840,7 +840,8 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
   llvm::SmallVector<mlir::Attribute> dependTypeOperands;
 
   Fortran::parser::OmpIfClause::DirectiveNameModifier directiveName;
-  llvm::omp::Directive directive;
+  // GCC 9.3.0 emits a (probably) bogus warning about an unused variable.
+  [[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