Skip to content

Commit a94c723

Browse files
committed
Instrument.C: properly error out when C source could not be parsed
If a C source can't be parsed, the resulting translation unit will be null. In this case, emit an error message and error out. gnatcov used to crash on an assertion failure. Change-Id: I4da2a21539ba23260f2308d6e9df8effd2bbff00 TN: V816-018
1 parent 29e9f90 commit a94c723

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tools/gnatcov/instrument-c.adb

+7
Original file line numberDiff line numberDiff line change
@@ -2547,6 +2547,13 @@ package body Instrument.C is
25472547
Unsaved_Files => null,
25482548
Num_Unsaved_Files => 0,
25492549
Options => 0);
2550+
if Self.TU = null then
2551+
Outputs.Error ("Failed to parse " & Filename);
2552+
Outputs.Error ("Please make sure that the original project can"
2553+
& " be compiled, and that the right set of"
2554+
& " options is passed to gnatcov instrument");
2555+
raise Xcov_Exit_Exc;
2556+
end if;
25502557
if Verbose then
25512558
Run_Diagnostics (Self.TU);
25522559
end if;

0 commit comments

Comments
 (0)