From: Jerry DeLisle Date: Thu, 13 Nov 2025 00:03:34 +0000 (-0800) Subject: Fortran: Mark type-spec iterators referenced. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1099ffffffe482cbe31c29dad40d8760a74c6e67;p=thirdparty%2Fgcc.git 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 --git a/gcc/fortran/match.cc b/gcc/fortran/match.cc index 60434c14ee2..e009c82b0bd 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 f5c498f6f27..45407a162e7 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()