AdaCore / libadalang-tools

Libadalang-based tools
GNU General Public License v3.0
16 stars 13 forks source link

gnattest: Utils.Drivers.Driver.Process_Files: logic bug with ignored switch #25

Open kilian-gebhardt opened 1 year ago

kilian-gebhardt commented 1 year ago

I hit the pragma Assert (Counter = 0); in https://github.com/AdaCore/libadalang-tools/blob/263158611cf1b073db6733a9aa247c3a16f086d3/src/utils-drivers.adb#LL128C11-L128C38 when invoking gnattest with one ignore file that contained more than 1 file name (say 5).

The issue is that Arg_Length (Cmd, Ignore) only provides the number of ignore files but not the actual number of file names in those ignore files:

N_File_Names : constant Natural := Num_File_Names (Cmd) - Arg_Length (Cmd, Ignore);
Counter        : Natural := N_File_Names;

Counter subsequently get's decremented on every non-ignored file. Since Counter = N_File_Names - 1, Counter = 4 when the assertion is hit.