diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSemaKinds.def | 5 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 2 | ||||
-rw-r--r-- | test/Sema/attr-cleanup.c | 2 | ||||
-rw-r--r-- | test/SemaObjC/attr-cleanup.m | 10 |
4 files changed, 15 insertions, 4 deletions
diff --git a/include/clang/Basic/DiagnosticSemaKinds.def b/include/clang/Basic/DiagnosticSemaKinds.def index 24bca6a0cf..e5e7f6eacf 100644 --- a/include/clang/Basic/DiagnosticSemaKinds.def +++ b/include/clang/Basic/DiagnosticSemaKinds.def @@ -412,8 +412,9 @@ DIAG(err_attribute_cleanup_arg_not_function, ERROR, DIAG(err_attribute_cleanup_func_must_take_one_arg, ERROR, "'cleanup' function %0 must take 1 parameter") DIAG(err_attribute_cleanup_func_arg_incompatible_type, ERROR, - "'cleanup' function %0 parameter has type %1, expected type %2") - + "'cleanup' function %0 parameter has type %1 which is incompatible with " + "type %2") + // Clang-Specific Attributes DIAG(err_attribute_iboutlet, ERROR, "'iboutlet' attribute can only be applied to instance variables or properties") diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index ce38edd7c5..fb8b795af2 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -955,7 +955,7 @@ static void HandleCleanupAttr(Decl *d, const AttributeList &Attr, Sema &S) { // If this ever proves to be a problem it should be easy to fix. QualType Ty = S.Context.getPointerType(VD->getType()); QualType ParamTy = FD->getParamDecl(0)->getType(); - if (Ty != ParamTy) { + if (S.CheckAssignmentConstraints(Ty, ParamTy) != Sema::Compatible) { S.Diag(Attr.getLoc(), diag::err_attribute_cleanup_func_arg_incompatible_type) << Attr.getParameterName() << ParamTy << Ty; diff --git a/test/Sema/attr-cleanup.c b/test/Sema/attr-cleanup.c index e5dd3a26d8..d239c1ade5 100644 --- a/test/Sema/attr-cleanup.c +++ b/test/Sema/attr-cleanup.c @@ -29,5 +29,5 @@ void c3(struct s a); void t2() { int v1 __attribute__((cleanup(c2))); // expected-error {{'cleanup' function 'c2' must take 1 parameter}} - int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s', expected type 'int *'}} + int v2 __attribute__((cleanup(c3))); // expected-error {{'cleanup' function 'c3' parameter has type 'struct s' which is incompatible with type 'int *'}} } diff --git a/test/SemaObjC/attr-cleanup.m b/test/SemaObjC/attr-cleanup.m new file mode 100644 index 0000000000..8490e6dd60 --- /dev/null +++ b/test/SemaObjC/attr-cleanup.m @@ -0,0 +1,10 @@ +// RUN: clang %s -verify -fsyntax-only + +@class NSString; + +void c1(id *a); + +void t1() +{ + NSString *s __attribute((cleanup(c1))); +} |