diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index ced91a87b65daf1d78ac0c348f7e5c2cdf60c7f2..2333b821c3f450ab8146f156eafb7570ac1a52a6 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,10 @@
+2007-01-04  Brooks Moses  <brooks.moses@codesourcery.com>
+
+	PR 30235
+	* interface.c (compare_actual_formal): check for
+	alternate returns when iterating over non-present
+	arguments.
+
 2007-01-04  Brooks Moses  <brooks.moses@codesourcery.com>
 
 	* invoke.texi: Update manpage copyright to include 2007.
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index dd1ac694521b581e0b973f41de2b3d1632576c77..7b0c4231b0e1d718e6811c6ea666c79c03374f85 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1455,6 +1455,13 @@ compare_actual_formal (gfc_actual_arglist ** ap,
     {
       if (new[i] != NULL)
 	continue;
+      if (f->sym == NULL)
+	{
+	  if (where)
+	    gfc_error ("Missing alternate return spec in subroutine call at %L",
+		       where);
+	  return 0;
+	}
       if (!f->sym->attr.optional)
 	{
 	  if (where)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0663f79bb8e5fb8a9517e57eb542c62ec0fad1f9..0309fad98f507319c37a718f558d3c4016b83cf6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-01-04  Brooks Moses  <brooks.moses@codesourcery.com>
+
+	PR 30235
+	* gfortran.dg/altreturn_2.f90: new test.
+
 2007-01-04  Tom Tromey  <tromey@redhat.com>
 
 	PR preprocessor/28165:
diff --git a/gcc/testsuite/gfortran.dg/altreturn_2.f90 b/gcc/testsuite/gfortran.dg/altreturn_2.f90
new file mode 100755
index 0000000000000000000000000000000000000000..d0556d0370d894be22586802b51b8ab151fe14e4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/altreturn_2.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+       program altreturn_2
+         call foo()  ! { dg-error "Missing alternate return" }
+       contains
+         subroutine foo(*)
+           return
+         end subroutine
+       end program