https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119836
--- Comment #4 from kargls at comcast dot net --- All intrinsic functions are simple, and therefore pure. The following patch should fix the issue with functions. A similar fix is needed for subroutine, but only a few intrinsic subroutine are pure or simple. I don't have the time today to poke at subroutines. diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc index cdf043b6411..f4e029bdda1 100644 --- a/gcc/fortran/resolve.cc +++ b/gcc/fortran/resolve.cc @@ -3243,7 +3243,8 @@ pure_stmt_function (gfc_expr *e, gfc_symbol *sym) /* Check if an impure function is allowed in the current context. */ -static bool check_pure_function (gfc_expr *e) +static bool +check_pure_function (gfc_expr *e) { const char *name = NULL; code_stack *stack; @@ -3258,9 +3259,16 @@ static bool check_pure_function (gfc_expr *e) if (stack->current->op == EXEC_BLOCK) saw_block = true; if (saw_block && stack->current->op == EXEC_DO_CONCURRENT) { - gfc_error ("Reference to impure function at %L inside a " - "DO CONCURRENT", &e->where); - return false; + bool is_pure = e->value.function.isym + || (e->value.function.esym + && (e->value.function.esym->attr.pure + || e->value.function.esym->attr.elemental)); + if (!is_pure) + { + gfc_error ("Reference to impure function at %L inside a " + "DO CONCURRENT", &e->where); + return false; + } } }