diff --git a/include/clang/Basic/Attr.td b/include/clang/Basic/Attr.td index df4b38d331c7ea82e156fa63b39d99f2281f4fab..f34034e32559d346f0a80d14cac7e3fd1ab6ff52 100644 --- a/include/clang/Basic/Attr.td +++ b/include/clang/Basic/Attr.td @@ -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]; } diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 45ca8dcaef9c448f10796034ebb1e3b2faba1147..7674aa485418993452e9f66f8bea5ffca2aa7b52 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -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(); } diff --git a/test/Sema/nonnull.c b/test/Sema/nonnull.c index 0e92654c28328542db7bae82a3e16394558b703c..b1f69208241b1e90bc2b981f9b77f666cdd480a0 100644 --- a/test/Sema/nonnull.c +++ b/test/Sema/nonnull.c @@ -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) {