@@ -79,12 +79,10 @@ subroutine compile_command_dump_toml(self, table, error)
79
79
! > Error handling
80
80
type (error_t), allocatable , intent (out ) :: error
81
81
82
- call self% destroy()
83
-
84
- call set_string(table, " directory" , self% directory, error, ' compile_command_t' )
85
- if (allocated (error)) return
86
82
call set_list(table, " arguments" , self% arguments, error)
87
83
if (allocated (error)) return
84
+ call set_string(table, " directory" , self% directory, error, ' compile_command_t' )
85
+ if (allocated (error)) return
88
86
call set_string(table, " file" , self% file, error, ' compile_command_t' )
89
87
if (allocated (error)) return
90
88
@@ -102,12 +100,14 @@ subroutine compile_command_load_toml(self, table, error)
102
100
! > Error handling
103
101
type (error_t), allocatable , intent (out ) :: error
104
102
105
- call get_value(table, " directory " , self% directory, error, ' compile_command_t ' )
106
- if ( allocated (error)) return
103
+ call self% destroy( )
104
+
107
105
call get_list(table, " arguments" , self% arguments, error)
108
- if (allocated (error)) return
109
- call get_value(table, " file" , self% file, error, ' compile_command_t' )
110
- if (allocated (error)) return
106
+ if (allocated (error)) return
107
+
108
+ ! Return unallocated value if not present
109
+ call get_value(table, " directory" , self% directory% s)
110
+ call get_value(table, " file" , self% file% s)
111
111
112
112
end subroutine compile_command_load_toml
113
113
@@ -316,8 +316,6 @@ subroutine cct_dump_toml(self, table, error)
316
316
integer :: stat, ii
317
317
type (toml_array), pointer :: array
318
318
319
- if (.not. allocated (self% command)) return
320
-
321
319
! Create array
322
320
call add_array(table, ' compile_commands' , array, stat= stat)
323
321
if (stat/= toml_stat% success .or. .not. associated (array)) then
@@ -349,20 +347,22 @@ subroutine cct_load_toml(self, table, error)
349
347
call self% destroy()
350
348
351
349
call get_value(table, key= ' compile_commands' , ptr= array, requested= .true. ,stat= stat)
352
-
350
+
353
351
if (stat/= toml_stat% success .or. .not. associated (array)) then
354
352
355
353
call fatal_error(error, " TOML table has no 'compile_commands' key" )
356
354
return
357
355
358
356
else
359
357
360
- n = len (array)
358
+ n = len (array)
359
+ if (n<= 0 ) return
360
+
361
361
allocate (self% command(n))
362
362
363
363
do i = 1 , n
364
364
call get_value(array, pos= i, ptr= elem, stat= stat)
365
- if (stat /= toml_stat% success) then
365
+ if (stat /= toml_stat% success .or. .not. associated (elem) ) then
366
366
call fatal_error(error, " Entry in 'compile_commands' field cannot be read" )
367
367
return
368
368
end if
0 commit comments