This is a GCC extension, Clang should accept the attribute without a warning for compatibility with GCC.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
There are a *lot* of attributes GCC supports that Clang does not, and we generally do not silence diagnostics with them as that usually does the user a disservice because they are unaware that the attribute has no effect under any circumstances. Given that: why is this change needed; is this attribute commonly used in some system header files?
(Maybe implementing real support isn't so difficult? From a quick glance, it sounds like this is a sema-only attribute?)
That makes sense for diagnostics, but this attribute is only an optimization hint, so compiler should be allowed to ignore it. I can take a look how difficult it'd be to actually implement this attribute, but I don't think it's Sema-only attribute. I don't know if there's a matching IR function attribute; it seems like readonly attribute has similar effect but I'd need to take a look at the exact semantics.
The compiler does ignore it; it even tells you it's ignoring it. ;-) There are other optimization-only attributes we don't support, similarly (such as __attribute__((optimize))).
Hopefully the attribute is something we can fully implement, but if it's not and this attribute isn't used by common system headers, I'd be opposed to silently ignoring it rather than vocally ignoring it.