llvm-project/clang/test/Sema/attr-ownership.cpp
Pavel Skripkin 150bf637ba
[Clang][Sema] Disallow applying onwership_returns to functions that return non-pointers (#99564)
`onwership_returns` works only with pointers, since it models
user-defined memory allocation functions. Make semantics more clear and
report an error if attribute is attached to wrong function.

Closes #99501
2024-07-29 18:43:50 +02:00

8 lines
315 B
C++

// RUN: %clang_cc1 %s -verify -fsyntax-only
class C {
void *f(int, int)
__attribute__((ownership_returns(foo, 2))) // expected-error {{'ownership_returns' attribute index does not match; here it is 2}}
__attribute__((ownership_returns(foo, 3))); // expected-note {{declared with index 3 here}}
};