https://gcc.gnu.org/g:74a2281ae18c6dbbc640f0c79f7138a495ef8f0c
commit r16-921-g74a2281ae18c6dbbc640f0c79f7138a495ef8f0c Author: Harald Anlauf <anl...@gmx.de> Date: Tue May 27 23:08:54 2025 +0200 Fortran: fix regression introduced by commit r16-914-g787a8dec1acedf A last-minute cleanup before patch submission reordered a change that should not have happened. This fixes it. PR fortran/101735 gcc/fortran/ChangeLog: * primary.cc (gfc_match_varspec): Correct order of logic. Diff: --- gcc/fortran/primary.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc index 426c994e67d1..db5fc5de8141 100644 --- a/gcc/fortran/primary.cc +++ b/gcc/fortran/primary.cc @@ -2686,16 +2686,17 @@ gfc_match_varspec (gfc_expr *primary, int equiv_flag, bool sub_flag, else if (component == NULL && !inquiry) return MATCH_ERROR; - /* Find end of reference chain if inquiry reference and tail not set. */ - if (tail == NULL && inquiry && tmp) - tail = extend_ref (primary, tail); - /* Extend the reference chain determined by gfc_find_component or is_inquiry_ref. */ if (primary->ref == NULL) primary->ref = tmp; else { + /* Find end of reference chain if inquiry reference and tail not + set. */ + if (tail == NULL && inquiry && tmp) + tail = extend_ref (primary, tail); + /* Set by the for loop below for the last component ref. */ gcc_assert (tail != NULL); tail->next = tmp;