[cfe-commits] r65461 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.def lib/Sema/SemaDeclAttr.cpp test/Sema/attr-cleanup.c test/SemaObjC/attr-cleanup.m

Anders Carlsson andersca at mac.com
Wed Feb 25 09:19:09 PST 2009


Author: andersca
Date: Wed Feb 25 11:19:08 2009
New Revision: 65461

URL: http://llvm.org/viewvc/llvm-project?rev=65461&view=rev
Log:
Use CheckAssignmentConstraints for checking the cleanup attr function. Fixes PR3656.

Added:
    cfe/trunk/test/SemaObjC/attr-cleanup.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/Sema/attr-cleanup.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def?rev=65461&r1=65460&r2=65461&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.def Wed Feb 25 11:19:08 2009
@@ -412,8 +412,9 @@
 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")

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=65461&r1=65460&r2=65461&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Feb 25 11:19:08 2009
@@ -955,7 +955,7 @@
   // 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;

Modified: cfe/trunk/test/Sema/attr-cleanup.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-cleanup.c?rev=65461&r1=65460&r2=65461&view=diff

==============================================================================
--- cfe/trunk/test/Sema/attr-cleanup.c (original)
+++ cfe/trunk/test/Sema/attr-cleanup.c Wed Feb 25 11:19:08 2009
@@ -29,5 +29,5 @@
 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 *'}}
 }

Added: cfe/trunk/test/SemaObjC/attr-cleanup.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-cleanup.m?rev=65461&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjC/attr-cleanup.m (added)
+++ cfe/trunk/test/SemaObjC/attr-cleanup.m Wed Feb 25 11:19:08 2009
@@ -0,0 +1,10 @@
+// RUN: clang %s -verify -fsyntax-only
+
+ at class NSString;
+
+void c1(id *a);
+
+void t1()
+{
+  NSString *s __attribute((cleanup(c1)));
+}





More information about the cfe-commits mailing list