add_compile_command_one Subroutine

public pure subroutine add_compile_command_one(list, new)

Add one compile command to array with a loop (gcc-15 bug on array initializer)

Arguments

Type IntentOptional Attributes Name
type(compile_command_t), intent(inout), allocatable :: list(:)
type(compile_command_t), intent(in) :: new

Variables

Type Visibility Attributes Name Initial
integer, public :: i
integer, public :: n
type(compile_command_t), public, allocatable :: tmp(:)

Source Code

    pure subroutine add_compile_command_one(list,new)
        type(compile_command_t), allocatable, intent(inout) :: list(:)
        type(compile_command_t), intent(in) :: new

        integer :: i,n
        type(compile_command_t), allocatable :: tmp(:)

        if (allocated(list)) then
           n = size(list)
        else
           n = 0
        end if

        allocate(tmp(n+1))
        do i=1,n
           tmp(i) = list(i)
        end do
        tmp(n+1) = new
        call move_alloc(from=tmp,to=list)

    end subroutine add_compile_command_one