Skip to content

Commit 4a10b4c

Browse files
authored
[flang] fix flang builds with clang 20 after #100692 (#106718)
#100692 changes clang template deduction, and an error was now emitted when building flang with top of the tree clang when mapping std::pow in intrinsics-library.cpp for constant folding `error: address of overloaded function 'pow' is ambiguous` See https://lab.llvm.org/buildbot/#/builders/4/builds/1670 I I am not expert enough to understand if the new error is justified or not here, but it is easy to help the compiler here with explicit wrappers to fix the builds.
1 parent 7ffe67c commit 4a10b4c

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,25 @@ struct HostRuntimeLibrary<HostT, LibraryVersion::Libm> {
255255
static constexpr HostRuntimeMap map{table};
256256
static_assert(map.Verify(), "map must be sorted");
257257
};
258+
259+
// Helpers to map complex std::pow whose resolution in F2{std::pow} is
260+
// ambiguous as of clang++ 20.
261+
template <typename HostT>
262+
static std::complex<HostT> StdPowF2(
263+
const std::complex<HostT> &x, const std::complex<HostT> &y) {
264+
return std::pow(x, y);
265+
}
266+
template <typename HostT>
267+
static std::complex<HostT> StdPowF2A(
268+
const HostT &x, const std::complex<HostT> &y) {
269+
return std::pow(x, y);
270+
}
271+
template <typename HostT>
272+
static std::complex<HostT> StdPowF2B(
273+
const std::complex<HostT> &x, const HostT &y) {
274+
return std::pow(x, y);
275+
}
276+
258277
template <typename HostT>
259278
struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
260279
using F = FuncPointer<std::complex<HostT>, const std::complex<HostT> &>;
@@ -275,9 +294,9 @@ struct HostRuntimeLibrary<std::complex<HostT>, LibraryVersion::Libm> {
275294
FolderFactory<F, F{std::cosh}>::Create("cosh"),
276295
FolderFactory<F, F{std::exp}>::Create("exp"),
277296
FolderFactory<F, F{std::log}>::Create("log"),
278-
FolderFactory<F2, F2{std::pow}>::Create("pow"),
279-
FolderFactory<F2A, F2A{std::pow}>::Create("pow"),
280-
FolderFactory<F2B, F2B{std::pow}>::Create("pow"),
297+
FolderFactory<F2, F2{StdPowF2}>::Create("pow"),
298+
FolderFactory<F2A, F2A{StdPowF2A}>::Create("pow"),
299+
FolderFactory<F2B, F2B{StdPowF2B}>::Create("pow"),
281300
FolderFactory<F, F{std::sin}>::Create("sin"),
282301
FolderFactory<F, F{std::sinh}>::Create("sinh"),
283302
FolderFactory<F, F{std::sqrt}>::Create("sqrt"),

0 commit comments

Comments
 (0)