[llvm] [offload] `gnu::format` with variadic template functions is Clang-only (PR #124406)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 25 05:29:31 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Michał Górny (mgorny)
<details>
<summary>Changes</summary>
Use `gnu::format` attribute only when compiling with Clang, as using it against variadic template functions is a Clang extension and is not supported by GCC.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
Fixes #<!-- -->119069
---
Full diff: https://github.com/llvm/llvm-project/pull/124406.diff
1 Files Affected:
- (modified) offload/plugins-nextgen/common/include/ErrorReporting.h (+12-6)
``````````diff
diff --git a/offload/plugins-nextgen/common/include/ErrorReporting.h b/offload/plugins-nextgen/common/include/ErrorReporting.h
index 8478977a8f86af..2ad0f2b7dd6c65 100644
--- a/offload/plugins-nextgen/common/include/ErrorReporting.h
+++ b/offload/plugins-nextgen/common/include/ErrorReporting.h
@@ -80,8 +80,10 @@ class ErrorReporter {
/// Print \p Format, instantiated with \p Args to stderr.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
- [[gnu::format(__printf__, 1, 2)]] static void print(const char *Format,
- ArgsTy &&...Args) {
+#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
+ [[gnu::format(__printf__, 1, 2)]]
+#endif
+ static void print(const char *Format, ArgsTy &&...Args) {
raw_fd_ostream OS(STDERR_FILENO, false);
OS << llvm::format(Format, Args...);
}
@@ -89,8 +91,10 @@ class ErrorReporter {
/// Print \p Format, instantiated with \p Args to stderr, but colored.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
- [[gnu::format(__printf__, 2, 3)]] static void
- print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
+#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
+ [[gnu::format(__printf__, 2, 3)]]
+#endif
+ static void print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
raw_fd_ostream OS(STDERR_FILENO, false);
WithColor(OS, HighlightColor(Color)) << llvm::format(Format, Args...);
}
@@ -99,8 +103,10 @@ class ErrorReporter {
/// a banner.
/// TODO: Allow redirection into a file stream.
template <typename... ArgsTy>
- [[gnu::format(__printf__, 1, 2)]] static void reportError(const char *Format,
- ArgsTy &&...Args) {
+#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
+ [[gnu::format(__printf__, 1, 2)]]
+#endif
+ static void reportError(const char *Format, ArgsTy &&...Args) {
print(BoldRed, "%s", ErrorBanner);
print(BoldRed, Format, Args...);
print("\n");
``````````
</details>
https://github.com/llvm/llvm-project/pull/124406
More information about the llvm-commits
mailing list