
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#patch6 Fixes: https://github.com/llvm/llvm-project/issues/51607 Partial-Bug: https://github.com/llvm/llvm-project/issues/53152
13 lines
509 B
C
13 lines
509 B
C
// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
|
|
|
|
int *Mem;
|
|
void dealloc(int*);
|
|
|
|
__attribute__((malloc)) int *MallocFunc(){ return Mem;}
|
|
// CHECK: define[[BEFORE:.*]] noalias[[AFTER:.*]]@MallocFunc
|
|
// Ensure these two do not generate noalias here.
|
|
__attribute__((malloc(dealloc))) int *MallocFunc2(){ return Mem;}
|
|
// CHECK: define[[BEFORE]][[AFTER]]@MallocFunc2
|
|
__attribute__((malloc(dealloc, 1))) int *MallocFunc3(){ return Mem;}
|
|
// CHECK: define[[BEFORE]][[AFTER]]@MallocFunc3
|