Index: gcc/fortran/trans-stmt.c
===================================================================
--- gcc/fortran/trans-stmt.c	(revision 192004)
+++ gcc/fortran/trans-stmt.c	(working copy)
@@ -5145,7 +5145,9 @@ gfc_trans_allocate (gfc_code * code)
 	      dataref = actual->next->expr->ref;
 	      /* Make sure we go up through the reference chain to
 		 the _data reference, where the arrayspec is found.  */
-	      while (dataref->next && dataref->next->type != REF_ARRAY)
+	      while (!(dataref->type == REF_COMPONENT
+		       && strcmp (dataref->u.c.component->name, "_data") == 0)
+		     && dataref->next)
 		dataref = dataref->next;
 
 	      if (dataref->u.c.component->as)
