https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68950
--- Comment #2 from vries at gcc dot gnu.org --- Using this patch: ... diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c index 8c4fa03..2669bf2 100644 --- a/gcc/fortran/trans-decl.c +++ b/gcc/fortran/trans-decl.c @@ -2097,7 +2097,9 @@ build_function_decl (gfc_symbol * sym, bool global) TREE_USED (fndecl) = 1; attributes = add_attributes_to_decl (attr, NULL_TREE); + gfc_diagnostics_finish (); decl_attributes (&fndecl, attributes, 0); + gfc_diagnostics_init (); /* Figure out the return type of the declared function, and build a RESULT_DECL for it. If this is a subroutine with alternate ... I avoid the assert, and get the error message: ... src/gcc/testsuite/gfortran.dg/goacc/routine-4.f90:151:0: Error: wrong number of arguments specified for ‘oacc function’ attribute src/gcc/testsuite/gfortran.dg/goacc/routine-4.f90:141:0: Error: wrong number of arguments specified for ‘oacc function’ attribute src/gcc/testsuite/gfortran.dg/goacc/routine-4.f90:131:0: Error: wrong number of arguments specified for ‘oacc function’ attribute src/gcc/testsuite/gfortran.dg/goacc/routine-4.f90:121:0: Error: wrong number of arguments specified for ‘oacc function’ attribute ...