From d6a99149ff003367c7a72ae8c4a11b471af71dfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sat, 25 Jan 2025 14:26:23 +0100 Subject: [PATCH] [offload] `gnu::format` with variadic template functions is Clang-only 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 --- .../common/include/ErrorReporting.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) 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 - [[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 - [[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 - [[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");