[llvm] [flang-rt] Explicitly define the default ShallowCopy* templates (PR #141619)
Kajetan Puchalski via llvm-commits
llvm-commits at lists.llvm.org
Tue May 27 08:16:57 PDT 2025
https://github.com/mrkajetanp created https://github.com/llvm/llvm-project/pull/141619
Not explicitly defining the default case for ShallowCopy* functions does not meet the requirements for gcc to actually instantiate the templates, leading to build errors that show up with gcc but not with clang.
>From 351a9aa456df1bb798611f2df82bb9683b703cb2 Mon Sep 17 00:00:00 2001
From: Kajetan Puchalski <kajetan.puchalski at arm.com>
Date: Tue, 27 May 2025 15:10:58 +0000
Subject: [PATCH] [flang-rt] Explicitly define the default ShallowCopy*
templates
Not explicitly defining the default case for ShallowCopy* functions
does not meet the requirements for gcc to actually instantiate the
templates, leading to build errors that show up with gcc but not with
clang.
Signed-off-by: Kajetan Puchalski <kajetan.puchalski at arm.com>
---
flang-rt/lib/runtime/tools.cpp | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/flang-rt/lib/runtime/tools.cpp b/flang-rt/lib/runtime/tools.cpp
index 027e1b0a4fb3a..b08195cd31e05 100644
--- a/flang-rt/lib/runtime/tools.cpp
+++ b/flang-rt/lib/runtime/tools.cpp
@@ -136,6 +136,10 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToDiscontiguous(
}
}
+// Explicitly instantiate the default case to conform to the C++ standard
+template RT_API_ATTRS void ShallowCopyDiscontiguousToDiscontiguous<char, -1>(
+ const Descriptor &to, const Descriptor &from);
+
template <typename P, int RANK>
RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous(
const Descriptor &to, const Descriptor &from) {
@@ -153,6 +157,9 @@ RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous(
}
}
+template RT_API_ATTRS void ShallowCopyDiscontiguousToContiguous<char, -1>(
+ const Descriptor &to, const Descriptor &from);
+
template <typename P, int RANK>
RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous(
const Descriptor &to, const Descriptor &from) {
@@ -170,6 +177,9 @@ RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous(
}
}
+template RT_API_ATTRS void ShallowCopyContiguousToDiscontiguous<char, -1>(
+ const Descriptor &to, const Descriptor &from);
+
// ShallowCopy helper for calling the correct specialised variant based on
// scenario
template <typename P, int RANK = -1>
More information about the llvm-commits
mailing list