[flang-commits] [flang] [Flang][#212316] Fix -Wunused-template errors under -Werror (PR #218985)
via flang-commits
flang-commits at lists.llvm.org
Sat Sep 12 01:29:21 PDT 2026
laoshd wrote:
> > he [[maybe_unused]] templates in flang/lib/Evaluate/tools.cpp and flang/lib/Semantics/check-cuda.cpp are actually used. Deleting them will cause build to fail. Those in other *.cpp under flang directory have been removed.
>
> In `tools.cpp` they are actually unused as far as I can tell. I do not get any compilation failures by removing them. `check-cuda.cpp` seems to have a false positive. Marking that `[[maybe_unused]]` is fine, but please add a comment that it should be removed when clang is fixed.
What clang fix is related to the failures of check-cuda.cpp with the templates removed? Is there a PR # or issue # that can be added to the comments?
The tools.cpp failures after removing the templates can be reproduced using the following script, which is copied from the build output when failed, slightly modified for easy port. The clang++ is the one actually used in the build:
```
cpp=/hpcdc/project/pe_users/laos/DATA/CMPLR/docker/docker.flang/clang/bin/clang++
build_dir=/ptmp/laos/llvm-flang_debug/builds_ntv
source_dir=/hpcdc/project/pe_users/laos/DATA/CMPLR/llvm-project_ntv
cd $build_dir/tools/flang/lib/Evaluate && \
$cpp \
-DFLANG_INCLUDE_TESTS=1 \
-DFLANG_RUNTIME_F128_MATH_LIB=\"libquadmath\" \
-DHAS_QUADMATHLIB \
-D_GLIBCXX_ASSERTIONS \
-D_GLIBCXX_USE_CXX11_ABI=1 \
-D_GNU_SOURCE \
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE \
-D__STDC_CONSTANT_MACROS \
-D__STDC_FORMAT_MACROS \
-D__STDC_LIMIT_MACROS \
-I$build_dir/tools/flang/lib/Evaluate \
-I$source_dir/flang/lib/Evaluate \
-I$source_dir/flang/include \
-I$build_dir/tools/flang/include \
-I$build_dir/include \
-I$source_dir/llvm/include \
-isystem $source_dir/flang/../mlir/include \
-isystem $build_dir/tools/mlir/include \
-isystem $build_dir/tools/clang/include \
-isystem $source_dir/llvm/../clang/include \
-march=native \
-fPIC \
-fno-semantic-interposition \
-fvisibility-inlines-hidden \
-Werror=date-time \
-Werror=unguarded-availability-new \
-Wall \
-Wextra \
-Wno-unused-parameter \
-Wwrite-strings \
-Wcast-qual \
-Wmissing-field-initializers \
-pedantic \
-Wno-long-long \
-Wc++98-compat-extra-semi \
-Wimplicit-fallthrough \
-Wcovered-switch-default \
-Wno-noexcept-type \
-Wnon-virtual-dtor \
-Wdelete-non-virtual-dtor \
-Wsuggest-override \
-Wstring-conversion \
-Wno-pass-failed \
-Wmisleading-indentation \
-Wctad-maybe-unsupported \
-ffunction-sections \
-fdata-sections \
-Xclang -fno-pch-timestamp \
-Werror \
-Wno-deprecated-copy \
-Wno-string-conversion \
-Wno-ctad-maybe-unsupported \
-Wno-unused-command-line-argument \
-Wstring-conversion \
-Wcovered-switch-default \
-Wno-nested-anon-types \
-O3 \
-DNDEBUG \
-std=c++17 \
-UNDEBUG \
-fno-exceptions \
-funwind-tables \
-fno-rtti \
-Winvalid-pch \
-Xclang -include-pch \
-Xclang $build_dir/tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/cmake_pch.hxx.pch \
-Xclang -include \
-Xclang $build_dir/tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/cmake_pch.hxx \
-MD \
-MT \
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o \
-MF \
CMakeFiles/FortranEvaluate.dir/tools.cpp.o.d \
-o CMakeFiles/FortranEvaluate.dir/tools.cpp.o \
-c \
$source_dir/flang/lib/Evaluate/tools.cpp
```
https://github.com/llvm/llvm-project/pull/218985
More information about the flang-commits
mailing list