Skip to content

Commit adba14a

Browse files
authored
Stop using __attribute__((retain)) in GCC builds (#133793)
GCC sometimes produces warnings about `__attribute__((retain))` despite `__has_attribute(retain)` being 1. See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587 The amount of users who benefit from the attribute is probably very small compared to the amount of `-Werror` enabled builds or the desire to keep `-Wattributes` enabled in the LLVM build. So for now drop usage of the `retain` attribute in GCC builds.
1 parent dc17429 commit adba14a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

llvm/include/llvm/Support/Compiler.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@
230230
#define LLVM_ATTRIBUTE_USED
231231
#endif
232232

233-
#if __has_attribute(retain)
233+
// Only enabled for clang:
234+
// See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99587
235+
// GCC may produce "warning: ‘retain’ attribute ignored" (despite
236+
// __has_attribute(retain) being 1).
237+
#if defined(__clang__) && __has_attribute(retain)
234238
#define LLVM_ATTRIBUTE_RETAIN __attribute__((__retain__))
235239
#else
236240
#define LLVM_ATTRIBUTE_RETAIN

0 commit comments

Comments
 (0)