================
@@ -1481,6 +1481,15 @@ static void handleOwnershipAttr(Sema &S, Decl *D, const
ParsedAttr &AL) {
break;
}
+ // Allow only pointers to be return type for functions with ownership_returns
+ // attribute. This matches with current OwnershipAttr::Takes semantics
+ if (K == OwnershipAttr::Returns) {
+ if (!getFunctionOrMethodResultType(D)->isPointerType()) {
+ S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
+ return;
+ }
+ }
----------------
AaronBallman wrote:
```suggestion
if (K == OwnershipAttr::Returns &&
!getFunctionOrMethodResultType(D)->isPointerType()) {
S.Diag(AL.getLoc(), diag::err_ownership_takes_return_type) << AL;
return;
}
```
(combining the two predicates, may need reformatting.)
https://github.com/llvm/llvm-project/pull/99564
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits