Skip to content

Conversation

@jeanPerier
Copy link
Contributor

Fix warning:

flang/lib/Lower/OpenACC.cpp:819:59: warning: parameter 'loc' set but not used [-Wunused-but-set-parameter]
  819 |           [&](mlir::OpBuilder &modBuilder, mlir::Location loc,
      |                                            ~~~~~~~~~~~~~~~^~~
flang/lib/Lower/OpenACC.cpp:820:29: warning: parameter 'globalOp' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |               ~~~~~~~~~~~~~~^~~~~~~~
flang/lib/Lower/OpenACC.cpp:820:61: warning: parameter 'clause' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~

Just use [[maybe_unsued]] to deal with the fact that these arguments are not always used because of the if constexpr.

@llvmbot llvmbot added flang Flang issues not falling into any other category flang:fir-hlfir openacc labels Oct 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 23, 2025

@llvm/pr-subscribers-openacc

Author: None (jeanPerier)

Changes

Fix warning:

flang/lib/Lower/OpenACC.cpp:819:59: warning: parameter 'loc' set but not used [-Wunused-but-set-parameter]
  819 |           [&](mlir::OpBuilder &modBuilder, mlir::Location loc,
      |                                            ~~~~~~~~~~~~~~~^~~
flang/lib/Lower/OpenACC.cpp:820:29: warning: parameter 'globalOp' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |               ~~~~~~~~~~~~~~^~~~~~~~
flang/lib/Lower/OpenACC.cpp:820:61: warning: parameter 'clause' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~

Just use [[maybe_unsued]] to deal with the fact that these arguments are not always used because of the if constexpr.


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

1 Files Affected:

  • (modified) flang/lib/Lower/OpenACC.cpp (+3-2)
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 1fc59c702fd81..d7861ac6463c8 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -816,8 +816,9 @@ static void genDeclareDataOperandOperations(
         Fortran::semantics::FindCommonBlockContaining(symbol)) {
       emitCommonGlobal(
           converter, builder, accObject, dataClause,
-          [&](mlir::OpBuilder &modBuilder, mlir::Location loc,
-              fir::GlobalOp globalOp, mlir::acc::DataClause clause,
+          [&](mlir::OpBuilder &modBuilder, [[maybe_unused]] mlir::Location loc,
+              [[maybe_unused]] fir::GlobalOp globalOp,
+              [[maybe_unused]] mlir::acc::DataClause clause,
               std::stringstream &asFortranStr, const std::string &ctorName) {
             if constexpr (std::is_same_v<EntryOp, mlir::acc::DeclareLinkOp>) {
               createDeclareGlobalOp<

@llvmbot
Copy link
Member

llvmbot commented Oct 23, 2025

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

Author: None (jeanPerier)

Changes

Fix warning:

flang/lib/Lower/OpenACC.cpp:819:59: warning: parameter 'loc' set but not used [-Wunused-but-set-parameter]
  819 |           [&amp;](mlir::OpBuilder &amp;modBuilder, mlir::Location loc,
      |                                            ~~~~~~~~~~~~~~~^~~
flang/lib/Lower/OpenACC.cpp:820:29: warning: parameter 'globalOp' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |               ~~~~~~~~~~~~~~^~~~~~~~
flang/lib/Lower/OpenACC.cpp:820:61: warning: parameter 'clause' set but not used [-Wunused-but-set-parameter]
  820 |               fir::GlobalOp globalOp, mlir::acc::DataClause clause,
      |                                       ~~~~~~~~~~~~~~~~~~~~~~

Just use [[maybe_unsued]] to deal with the fact that these arguments are not always used because of the if constexpr.


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

1 Files Affected:

  • (modified) flang/lib/Lower/OpenACC.cpp (+3-2)
diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp
index 1fc59c702fd81..d7861ac6463c8 100644
--- a/flang/lib/Lower/OpenACC.cpp
+++ b/flang/lib/Lower/OpenACC.cpp
@@ -816,8 +816,9 @@ static void genDeclareDataOperandOperations(
         Fortran::semantics::FindCommonBlockContaining(symbol)) {
       emitCommonGlobal(
           converter, builder, accObject, dataClause,
-          [&](mlir::OpBuilder &modBuilder, mlir::Location loc,
-              fir::GlobalOp globalOp, mlir::acc::DataClause clause,
+          [&](mlir::OpBuilder &modBuilder, [[maybe_unused]] mlir::Location loc,
+              [[maybe_unused]] fir::GlobalOp globalOp,
+              [[maybe_unused]] mlir::acc::DataClause clause,
               std::stringstream &asFortranStr, const std::string &ctorName) {
             if constexpr (std::is_same_v<EntryOp, mlir::acc::DeclareLinkOp>) {
               createDeclareGlobalOp<

Copy link
Contributor

@rscottmanley rscottmanley left a comment

Choose a reason for hiding this comment

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

Thanks for removing the warnings!

@jeanPerier jeanPerier merged commit 911e5aa into llvm:main Oct 23, 2025
14 checks passed
@jeanPerier jeanPerier deleted the fix_acc_warning branch October 23, 2025 12:07
dvbuka pushed a commit to dvbuka/llvm-project that referenced this pull request Oct 27, 2025
Fix warning about unused arguments. Just use [[maybe_unsued]] to deal with
the fact that these arguments are not always used because of the `if constexpr`.
Lukacma pushed a commit to Lukacma/llvm-project that referenced this pull request Oct 29, 2025
Fix warning about unused arguments. Just use [[maybe_unsued]] to deal with
the fact that these arguments are not always used because of the `if constexpr`.
aokblast pushed a commit to aokblast/llvm-project that referenced this pull request Oct 30, 2025
Fix warning about unused arguments. Just use [[maybe_unsued]] to deal with
the fact that these arguments are not always used because of the `if constexpr`.
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 openacc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants