Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flang] Add [[maybe_unused]] to fix -Werror build #83456

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Conversation

klausler
Copy link
Contributor

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.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir labels Feb 29, 2024
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 29, 2024

@llvm/pr-subscribers-flang-fir-hlfir

Author: Peter Klausler (klausler)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/83456.diff

1 Files Affected:

  • (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+1-1)
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;

Copy link
Contributor

@psteinfeld psteinfeld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Note that this looks like a compiler bug to me. The variable directive is used on line 873, so this warning should not appear.

Thanks for fixing this!

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.
@klausler klausler merged commit 5225901 into llvm:main Feb 29, 2024
3 of 4 checks passed
@klausler klausler deleted the unused branch February 29, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flang:fir-hlfir flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants