Skip to content

Commit 359a913

Browse files
authored
[offload] gnu::format with variadic template functions is Clang-only (#124406)
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
1 parent 3e5640b commit 359a913

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

offload/plugins-nextgen/common/include/ErrorReporting.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,21 @@ class ErrorReporter {
8080
/// Print \p Format, instantiated with \p Args to stderr.
8181
/// TODO: Allow redirection into a file stream.
8282
template <typename... ArgsTy>
83-
[[gnu::format(__printf__, 1, 2)]] static void print(const char *Format,
84-
ArgsTy &&...Args) {
83+
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
84+
[[gnu::format(__printf__, 1, 2)]]
85+
#endif
86+
static void print(const char *Format, ArgsTy &&...Args) {
8587
raw_fd_ostream OS(STDERR_FILENO, false);
8688
OS << llvm::format(Format, Args...);
8789
}
8890

8991
/// Print \p Format, instantiated with \p Args to stderr, but colored.
9092
/// TODO: Allow redirection into a file stream.
9193
template <typename... ArgsTy>
92-
[[gnu::format(__printf__, 2, 3)]] static void
93-
print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
94+
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
95+
[[gnu::format(__printf__, 2, 3)]]
96+
#endif
97+
static void print(ColorTy Color, const char *Format, ArgsTy &&...Args) {
9498
raw_fd_ostream OS(STDERR_FILENO, false);
9599
WithColor(OS, HighlightColor(Color)) << llvm::format(Format, Args...);
96100
}
@@ -99,8 +103,10 @@ class ErrorReporter {
99103
/// a banner.
100104
/// TODO: Allow redirection into a file stream.
101105
template <typename... ArgsTy>
102-
[[gnu::format(__printf__, 1, 2)]] static void reportError(const char *Format,
103-
ArgsTy &&...Args) {
106+
#ifdef __clang__ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77958
107+
[[gnu::format(__printf__, 1, 2)]]
108+
#endif
109+
static void reportError(const char *Format, ArgsTy &&...Args) {
104110
print(BoldRed, "%s", ErrorBanner);
105111
print(BoldRed, Format, Args...);
106112
print("\n");

0 commit comments

Comments
 (0)