[flang-commits] [flang] [flang][OpenMP] Silence unused-but-set-variable message (NFC) (PR #130979)
via flang-commits
flang-commits at lists.llvm.org
Tue Mar 18 09:27:24 PDT 2025
jeanPerier wrote:
> Personally, what I think speaks against it is that it introduces yet another unused variable. If there are two unused variables in the same scope, they also need different names. When the type is non-trivial, it may involve runtime costs by e.g. calling a copy-ctor which is not guaranteed to be optimized away, including in debug builds.
Right, but that part is specific to this patch (granted, I did not catch it), because the C++17 canonical way to do it would have been to do `if([[maybe_unused]] auto *symRef = base.UnwrapSymbolRef()) { ...`.
Anyway, I am OK with the C style cast, I just think the only reason LLVM doc is advising to use that is because this section was written before C++17 was LLVM default and compilers add support for it ([13 years ago](https://github.com/llvm/llvm-project/commit/1c5e94a47c1c68b35b9d32bc2558eefbe5a85b5f) to be more specific). I think there is nothing wrong with `[[maybe_unused]]` when put at the correct place.
https://github.com/llvm/llvm-project/pull/130979
More information about the flang-commits
mailing list