[clang] [clang] Ignore GCC 11 `[[malloc(x)]]` attribute (PR #68059)

Alois Klink via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 7 11:46:54 PDT 2023


aloisklink wrote:

> We generally want ignored attributes to be diagnosed as being ignored; otherwise users have a much harder time determining whether the attribute is working or not. I think we should issue an "attribute ignored" warning when we're dropping the attribute in the AST.

Personally, I think there shouldn't be a warning, because even if we add the attribute to the AST, Clang will do nothing with it; the attribute would only be used by Clang's static analyzer. But I've added a warning anyway in https://github.com/llvm/llvm-project/commit/a76561f522f628b0882572f8dabee6f7e4abd5f5.

I think a generic `'malloc' attribute ignored` warning would have been pretty confusing, (especially because most of the time, people use both the no-argument form and the one/two argument form on the same function, e.g. `__attribute__((malloc, malloc(my_cleanup))) void *my_func();`) so instead I've made a custom warning that says: `'malloc' attribute ignored because Clang does not support the one/two argument form`.

> Also, the changes should come with a release note so that users know about the bug fix.

:+1: That makes sense! I've added a note in the **Bug Fixes to Attribute Support** section in https://github.com/llvm/llvm-project/commit/a76561f522f628b0882572f8dabee6f7e4abd5f5.

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


More information about the cfe-commits mailing list