https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96255

--- Comment #30 from anlauf at gcc dot gnu.org ---
(In reply to Jerry DeLisle from comment #29)
> (In reply to Christopher Albert from comment #28)
> > Created attachment 62769 [details]
> > Follow-up to remove incorrect warnings about unreferenced variables
> > 
> > Is it really that simple?
> 
> Intuitively, the iterators are used by the loop processing so I think this
> is correct. If no one else chimes in, I will push this as well. My
> prelkiminary testing is good. I have a little more to do.

I agree with the changes to match.cc, but disagree with the changes to the
testcase.

-! { dg-options "-std=f2008" }
+! { dg-options "-std=f2008 -Wall" }

This is OK.

+! { dg-bogus "Unused variable '_i' declared" }
+! { dg-bogus "Unused variable '_k' declared" }
+! { dg-bogus "Unused variable 'n' declared" }

This is not OK, as there should be no warning.

+  subroutine test_unused_new_iterator()
+    implicit none
+    integer :: iter_count
+
+    iter_count = 0
+    do concurrent (integer :: n = 1:4)
+      iter_count = iter_count + 1
+    end do
+
+    if (iter_count /= 4) stop 10
+  end subroutine test_unused_new_iterator

This is problematic: you should either declare a reduction operation, which
is already tested elsewhere, or just drop this part.

Note that an iterator variable is used by definition, and we currently do
not warn for empty loops, as in:

do i = 1, 2
end do

do concurrent (j = 1:2)
end do

do concurrent (integer :: k = 1:2)
end do

end

Reply via email to