]> granicus.if.org Git - clang/commitdiff
Correct the order of the parameters to CheckAssignmentConstraints in
authorEli Friedman <eli.friedman@gmail.com>
Sun, 26 Apr 2009 01:30:08 +0000 (01:30 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 26 Apr 2009 01:30:08 +0000 (01:30 +0000)
cleanup attribute checking.  The difference isn't normally visible, but it
can make a difference...

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70104 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/Sema/attr-cleanup.c

index 8843d92c5cae35f41663729c84d53e7cb83fdb46..c0a3b44c43ef9d3abc0290a85a19f16def654758 100644 (file)
@@ -1013,7 +1013,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 (S.CheckAssignmentConstraints(Ty, ParamTy) != Sema::Compatible) {
+  if (S.CheckAssignmentConstraints(ParamTy, Ty) != Sema::Compatible) {
     S.Diag(Attr.getLoc(), 
            diag::err_attribute_cleanup_func_arg_incompatible_type) <<
       Attr.getParameterName() << ParamTy << Ty;
index 69896083f062de4452f0fc83d750b084d644537d..0434981c6c4aff314d896c6d1bed609d61c347ef 100644 (file)
@@ -31,3 +31,10 @@ 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' which is incompatible with type 'int *'}}
 }
+
+// This is a manufactured testcase, but gcc accepts it...
+void c4(_Bool a);
+void t4() {
+  __attribute((cleanup(c4))) void* g;
+}
+