2017-06-29 Cesar Philippidis PR fortran/77765 gcc/fortran/ * openmp.c (gfc_match_oacc_routine): Check if proc_name exist before comparing the routine name against it. gcc/testsuite/ * gfortran.dg/goacc/pr77765.f90: New test. diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 1d191d2..236ecb2 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -2474,7 +2474,8 @@ gfc_match_oacc_routine (void) if (st) { sym = st->n.sym; - if (strcmp (sym->name, gfc_current_ns->proc_name->name) == 0) + if (gfc_current_ns->proc_name != NULL + && strcmp (sym->name, gfc_current_ns->proc_name->name) == 0) sym = NULL; } else if (isym == NULL) diff --git a/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 b/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 new file mode 100644 index 0000000..3819cf7 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr77765.f90 @@ -0,0 +1,19 @@ +! Test the presence of an ACC ROUTINE directive inside a function +! containg an error. + +! { dg-do compile } + +module m +contains + recursive function f(x) + end function f + recursive function f(x) + !$acc routine (f) + end function f +end module m + +! { dg-error "Procedure 'f' at .1. is already defined" "" { target *-*-* } 8 } +! { dg-error "Duplicate RECURSIVE attribute specified" "" { target *-*-* } 8 } +! { dg-error ".1." "" { target *-*-* } 10 } +! { dg-error "Unexpected ..ACC ROUTINE" "" { target *-*-* } 11 } +! { dg-error "Expecting END MODULE statement" "" { target *-*-* } 12 }