summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-02-25 17:19:08 +0000
committerAnders Carlsson <andersca@mac.com>2009-02-25 17:19:08 +0000
commitf2f2e7f6a127f4559cbc6e17c6187a1abbeb0d82 (patch)
treeadce4726c36392b5e0e3c6dc561531e6473b7df7
parent739ef0c183fa9031f82494d9df56170f3254e5b0 (diff)
downloadbcm5719-llvm-f2f2e7f6a127f4559cbc6e17c6187a1abbeb0d82.tar.gz
bcm5719-llvm-f2f2e7f6a127f4559cbc6e17c6187a1abbeb0d82.zip
Use CheckAssignmentConstraints for checking the cleanup attr function. Fixes PR3656.
llvm-svn: 65461
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.def5
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp2
-rw-r--r--clang/test/Sema/attr-cleanup.c2
-rw-r--r--clang/test/SemaObjC/attr-cleanup.m10
4 files changed, 15 insertions, 4 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.def b/clang/include/clang/Basic/DiagnosticSemaKinds.def
index 24bca6a0cf2..e5e7f6eacf1 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.def
+++ b/clang/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/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index ce38edd7c5f..fb8b795af22 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/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/clang/test/Sema/attr-cleanup.c b/clang/test/Sema/attr-cleanup.c
index e5dd3a26d8a..d239c1ade51 100644
--- a/clang/test/Sema/attr-cleanup.c
+++ b/clang/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/clang/test/SemaObjC/attr-cleanup.m b/clang/test/SemaObjC/attr-cleanup.m
new file mode 100644
index 00000000000..8490e6dd604
--- /dev/null
+++ b/clang/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)));
+}
OpenPOWER on IntegriCloud