Resolving name conflicts of input variables with Fortran instrinsics

I also get the same warning, and it seems to be a known issue. If it is “spurious”, hopefully harmless (false positive)…?

59107 – [8/9/10/11 Regression] Spurious "Type specified for intrinsic function 'command_argument_count' at (1) is ignored" under -Wsurprising.

This is another (very similar) post, related to overloading:
-Wsurprising warning for overloaded intrinsic size

The block method of FortranFan also seems interesting (thanks!), which does not give warning for me (gfortran-10). It might be another possibility to use a local alias (pointer or associate) of the size argument like…

pointer version
module test_m
    implicit none
contains
subroutine sub( size, arr )
    integer, target :: size
    integer :: arr(:)
    integer, pointer :: size_   !! local alias
    size_ => size
    block
    intrinsic :: size

    !( body of the routine )
    print *, size( arr ), size_

    endblock
end
end module

program main
    use test_m
    call sub( size=777, arr=[1,2,3] )
end
associate version
module test_m
    implicit none
contains
subroutine sub( size, arr )
    integer :: size
    integer :: arr(:)
    associate( size_ => size ); block
    intrinsic :: size

    !( body of the routine )
    print *, size( arr ), size_

    end block; end associate
end
end module

program main
    use test_m
    call sub( size=777, arr=[1,2,3] )
end