The returns_nonnull attribute does not require a function prototype because it affects only the return value, not any arguments. In turn, asking for a function or method result type should not require a function prototype either, so getFunctionOrMethodResultType has been relaxed.

llvm-svn: 212827
This commit is contained in:
Aaron Ballman 2014-07-11 16:31:29 +00:00
parent 923121e85b
commit 6288d0648a
3 changed files with 4 additions and 3 deletions

View File

@ -855,7 +855,7 @@ def NonNull : InheritableAttr {
def ReturnsNonNull : InheritableAttr {
let Spellings = [GCC<"returns_nonnull">];
let Subjects = SubjectList<[ObjCMethod, HasFunctionProto], WarnDiag,
let Subjects = SubjectList<[ObjCMethod, Function], WarnDiag,
"ExpectedFunctionOrMethod">;
let Documentation = [Undocumented];
}

View File

@ -90,7 +90,7 @@ static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) {
static QualType getFunctionOrMethodResultType(const Decl *D) {
if (const FunctionType *FnTy = D->getFunctionType())
return cast<FunctionProtoType>(FnTy)->getReturnType();
return cast<FunctionType>(FnTy)->getReturnType();
return cast<ObjCMethodDecl>(D)->getReturnType();
}

View File

@ -38,7 +38,8 @@ void *test_ptr_returns_nonnull(void) __attribute__((returns_nonnull)); // no-war
int i __attribute__((nonnull)); // expected-warning {{'nonnull' attribute only applies to functions, methods, and parameters}}
int j __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
void *test_no_fn_proto() __attribute__((returns_nonnull)); // expected-warning {{'returns_nonnull' attribute only applies to functions and methods}}
void *test_no_fn_proto() __attribute__((returns_nonnull)); // no-warning
void *test_with_fn_proto(void) __attribute__((returns_nonnull)); // no-warning
__attribute__((returns_nonnull))
void *test_bad_returns_null(void) {