diff --git a/gcc/objc/ChangeLog b/gcc/objc/ChangeLog
index 949b92d2c36bcaeed5503e4702d19c3b103e134b..1b2bb353abb34a2f61586954b1f0ab1734361018 100644
--- a/gcc/objc/ChangeLog
+++ b/gcc/objc/ChangeLog
@@ -1,3 +1,8 @@
+2011-05-20  Nathan Froyd  <froydnj@codesourcery.com>
+
+	* objc-act.c (objc_compare_types): Use function_args_iterator
+	instead of TYPE_ARG_TYPES to compare function argument types.
+
 2011-05-13  Toon Moene  <toon@moene.org>
 
 	* objc-next-runtime-abi-02.c (newabi_append_ro):
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 7e69b0dbf59f08d736f5c4abd4f4a092e9f1354e..0e15fe55aa798d1ab52e456d285406b51bca4f03 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -2420,6 +2420,8 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee)
      lenient than C or C++ on this.  */
   if (TREE_CODE (ltyp) == FUNCTION_TYPE && TREE_CODE (rtyp) == FUNCTION_TYPE)
     {
+      function_args_iterator liter, riter;
+
       /* Return types must be covariant.  */
       if (!comptypes (TREE_TYPE (ltyp), TREE_TYPE (rtyp))
 	  && !objc_compare_types (TREE_TYPE (ltyp), TREE_TYPE (rtyp),
@@ -2427,16 +2429,31 @@ objc_compare_types (tree ltyp, tree rtyp, int argno, tree callee)
       return false;
 
       /* Argument types must be contravariant.  */
-      for (ltyp = TYPE_ARG_TYPES (ltyp), rtyp = TYPE_ARG_TYPES (rtyp);
-	   ltyp && rtyp; ltyp = TREE_CHAIN (ltyp), rtyp = TREE_CHAIN (rtyp))
+      function_args_iter_init (&liter, ltyp);
+      function_args_iter_init (&riter, rtyp);
+
+      while (1)
 	{
-	  if (!comptypes (TREE_VALUE (rtyp), TREE_VALUE (ltyp))
-	      && !objc_compare_types (TREE_VALUE (rtyp), TREE_VALUE (ltyp),
-				      argno, callee))
+	  ltyp = function_args_iter_cond (&liter);
+	  rtyp = function_args_iter_cond (&riter);
+
+	  /* If we've exhaused both lists simulateously, we're done.  */
+	  if (ltyp == NULL_TREE && rtyp == NULL_TREE)
+	    break;
+
+	  /* If one list is shorter than the other, they fail to match.  */
+	  if (ltyp == NULL_TREE || rtyp == NULL_TREE)
 	    return false;
-      }
 
-      return (ltyp == rtyp);
+	  if (!comptypes (rtyp, ltyp)
+	      && !objc_compare_types (rtyp, ltyp, argno, callee))
+	    return false;
+
+	  function_args_iter_next (&liter);
+	  function_args_iter_next (&riter);
+	}
+
+      return true;
     }
 
   /* Past this point, we are only interested in ObjC class instances,