[clang] Warning for incorrect useof 'pure' attribute (PR #78200)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 11:12:08 PST 2024


AaronBallman wrote:

> > The changes should also come with a release note so users know about the improved diagnostics.
> 
> Dont know how to do it, can you please reference what i need to do?

Modify https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst to have a new entry under `Improvements to Clang's diagnostics`

> > How about: '%select{pure|const}0' attribute applied to a function which %select{returns 'void'|has no return value}1; attribute ignored? Then it handles both situations, both attributes, and we don't need to invent a new warning group (it can go under IgnoredAttributes).
> 
> -Current behavior: silent UB -I think how this should work in future: valid and special case of [[pure]] -This PR: warning + UB
> But now i dont think it is not a good idea to ignore attribute, because GCC does not ignores it (so, code will work until compiled with GCC and breaks)

GCC doesn't define the behavior in these cases, right? If so, then the code is nonportable to begin with and dropping the attribute + warning about ignoring them seems like the correct behavior.

https://github.com/llvm/llvm-project/pull/78200


More information about the cfe-commits mailing list