https://gcc.gnu.org/g:1099ffffffe482cbe31c29dad40d8760a74c6e67
commit r16-5208-g1099ffffffe482cbe31c29dad40d8760a74c6e67 Author: Jerry DeLisle <[email protected]> Date: Wed Nov 12 16:03:34 2025 -0800 Fortran: Mark type-spec iterators referenced. Mark DO CONCURRENT iterators created via a type-spec as referenced so that generated shadow names are not warned about under -Wall. PR fortran/96255 gcc/fortran/ChangeLog: * match.cc (apply_typespec_to_iterator): Call gfc_set_sym_referenced for both new and shadow iterator symbols. gcc/testsuite/ChangeLog: * gfortran.dg/do_concurrent_typespec_1.f90: Update testcase to check for bugus warnings. Diff: --- gcc/fortran/match.cc | 2 ++ gcc/testsuite/gfortran.dg/do_concurrent_typespec_1.f90 | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 60434c14ee27..e009c82b0bd0 100644 --- a/gcc/fortran/match.cc +++ b/gcc/fortran/match.cc @@ -2630,6 +2630,7 @@ apply_typespec_to_iterator (gfc_forall_iterator *iter, gfc_typespec *ts, /* Variable not declared in outer scope - just set the type. */ v->ts.type = v->symtree->n.sym->ts.type = BT_INTEGER; v->ts.kind = v->symtree->n.sym->ts.kind = ts->kind; + gfc_set_sym_referenced (v->symtree->n.sym); } else { @@ -2651,6 +2652,7 @@ apply_typespec_to_iterator (gfc_forall_iterator *iter, gfc_typespec *ts, v->symtree = st; gfc_replace_expr (iter->var, v); iter->shadow = true; + gfc_set_sym_referenced (st->n.sym); } /* Convert iterator bounds to the specified type. */ diff --git a/gcc/testsuite/gfortran.dg/do_concurrent_typespec_1.f90 b/gcc/testsuite/gfortran.dg/do_concurrent_typespec_1.f90 index f5c498f6f278..45407a162e7d 100644 --- a/gcc/testsuite/gfortran.dg/do_concurrent_typespec_1.f90 +++ b/gcc/testsuite/gfortran.dg/do_concurrent_typespec_1.f90 @@ -1,5 +1,8 @@ ! { dg-do run } -! { dg-options "-std=f2008" } +! { dg-options "-std=f2008 -Wall" } +! { dg-bogus "Unused variable '_i' declared" } +! { dg-bogus "Unused variable '_k' declared" } +! { dg-bogus "Unused variable 'n' declared" } ! ! PR fortran/96255 ! Test DO CONCURRENT with optional type specification @@ -29,8 +32,6 @@ program test_do_concurrent_typespec call test_multiple_iterators() test_count = test_count + 1 - print *, "All", test_count, "tests passed" - contains subroutine test_no_outer_var()
