https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114141
--- Comment #14 from Paul Thomas <pault at gcc dot gnu.org> --- To fix the parentheses wrinkle, this works: diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index eee569dac91..64f61c50c66 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -1963,6 +1963,20 @@ gfc_match_associate (void) goto assocListError; } + /* If the selector expression is enclosed in parentheses and the + expression is not a variable, throw the parentheses away. */ + while (newAssoc->target->expr_type == EXPR_OP + && newAssoc->target->value.op.op == INTRINSIC_PARENTHESES) + { + if (newAssoc->target->value.op.op1->expr_type == EXPR_VARIABLE) + break; + else + { + gfc_expr *e = gfc_copy_expr (newAssoc->target->value.op.op1); + gfc_replace_expr (newAssoc->target, e); + } + } + /* The `variable' field is left blank for now; because the target is not To maintain compatibility with https://gcc.gnu.org/pipermail/fortran/2024-January/060092.html: @@ -2220,7 +2235,8 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, || tgt_expr->symtree->n.sym->attr.if_source == IFSRC_DECL); permissible = permissible - || (tgt_expr && tgt_expr->expr_type == EXPR_OP); + || (tgt_expr && (tgt_expr->expr_type == EXPR_OP + || (inquiry && tgt_expr->expr_type == EXPR_FUNCTION))); if (permissible) {