You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ignore the `[[malloc(x)]]` or `[[malloc(x, 1)]]` function attribute
syntax added in [GCC 11][1] and print a warning instead of an error.
Unlike `[[malloc]]` with no arguments (which is supported by Clang),
GCC uses the one or two argument form to specify a deallocator for
GCC's static analyzer.
Code currently compiled with `[[malloc(x)]]` or
`__attribute((malloc(x)))` fails with the following error:
`'malloc' attribute takes no arguments`.
[1]: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;f=gcc/doc/extend.texi;h=dce6c58db87ebf7f4477bd3126228e73e4eeee97#patch6Fixes: #51607
Partial-Bug: #53152
inline __attribute__((noreturn(a))) void*f1(void); // expected-error {{'noreturn' attribute takes no arguments}}
5
5
inline __attribute__((always_inline(a))) void*f2(void); // expected-error {{'always_inline' attribute takes no arguments}}
6
6
inline __attribute__((cdecl(a))) void*f3(void); // expected-error {{'cdecl' attribute takes no arguments}}
7
7
inline __attribute__((const(a))) void*f4(void); // expected-error {{'const' attribute takes no arguments}}
8
8
inline __attribute__((fastcall(a))) void*f5(void); // expected-error {{'fastcall' attribute takes no arguments}}
9
-
inline __attribute__((malloc(a))) void*f5(void); // expected-error {{'malloc' attribute takes no arguments}}
9
+
inline __declspec(restrict(a)) void*f6_a(void); // expected-error {{'restrict' attribute takes no arguments}}
10
+
inline __attribute__((malloc(a, 1, a))) void*f6_b(void); // expected-error {{'malloc' attribute takes no more than 2 arguments}}
11
+
inline __attribute__((malloc(a, 1))) void*f6_c(void); // expected-warning {{'malloc' attribute ignored because Clang does not support the one/two argument form}}
10
12
inline __attribute__((nothrow(a))) void*f7(void); // expected-error {{'nothrow' attribute takes no arguments}}
11
13
inline __attribute__((stdcall(a))) void*f8(void); // expected-error {{'stdcall' attribute takes no arguments}}
12
14
inline __attribute__((used(a))) void*f9(void); // expected-error {{'used' attribute takes no arguments}}
0 commit comments