2017-04-27 Cesar Philippidis 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. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 0aecda4..72c6669 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -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; diff --git a/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 b/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 new file mode 100644 index 0000000..4d8b5ba --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/routine-10.f90 @@ -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" }