2017-04-27 Cesar Philippidis <cesar@codesourcery.com>
gcc/fortran/
* openmp.c (gfc_match_oacc_routine): Don't match OpenACC routines
when the current function failed to parse due to a syntax error.
gcc/testsuite/
* gfortran.dg/goacc/routine-10.f90: New test.
@@ -2576,7 +2576,9 @@ gfc_match_oacc_routine (void)
goto cleanup;
}
else
- gcc_unreachable ();
+ /* Something has gone wrong. Perhaps there was a syntax error
+ in the program-stmt. */
+ goto cleanup;
if (n)
n->clauses = c;
new file mode 100644
@@ -0,0 +1,8 @@
+! Ensure that GFortran doesn't ICE with incomplete function
+! definitions.
+
+! { dg-do compile }
+
+integer function f1 ! { dg-error "Expected formal argument list in function definition" }
+ !$acc routine ! { dg-error "Unclassifiable OpenACC directive" }
+end function f1 ! { dg-error "Expecting END PROGRAM statement" }