================ @@ -614,9 +619,23 @@ static bool checkTryLockFunAttrCommon(Sema &S, Decl *D, const ParsedAttr &AL, return false; } - // check that all arguments are lockable objects + // Check that all remaining arguments are lockable objects. checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1); + // Check that the attribute is applied to a function. + if (!D->isFunctionOrFunctionTemplate()) { + return false; + } + // Check that the function returns a boolean, integer, or pointer. + QualType ReturnType = D->getAsFunction()->getReturnType(); + if (!ReturnType->isBooleanType() && !ReturnType->isIntegerType() && + !ReturnType->isPointerType()) { + S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type) + << AL << AL.isRegularKeywordAttribute() + << ExpectedFunctionReturningBoolIntegerOrPointer; + return false; + } + return true; } ---------------- dmcardle wrote:
I'm adding a some new logic for checking the success argument type. If I leave this as is, they will have the same style. If you feel strongly, I'm happy to apply DeMorgan's law here :) https://github.com/llvm/llvm-project/pull/95290 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits