Skip to content

Commit 03df974

Browse files
committed
Instrument.C: do not yield "unknown warning" warnings
gnatcov used to yield "unknown warning" warnings on warning switches not recognized by clang. Fix this by passing the "-Wno-unknown-warning-option" when parsing with clang.
1 parent 78034c3 commit 03df974

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
int
2+
main (int argc, char **argv)
3+
{
4+
return 0;
5+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""
2+
Check that gnatcov does not yield "unknown warning warnings" when parsing a
3+
file with warnings not recognized by clang.
4+
"""
5+
6+
from SCOV.minicheck import build_run_and_coverage, check_xcov_reports
7+
from SUITE.context import thistest
8+
from SUITE.cutils import Wdir
9+
from SUITE.tutils import gprfor
10+
from SUITE.gprutils import GPRswitches
11+
12+
tmp = Wdir("tmp_")
13+
14+
build_run_and_coverage(
15+
gprsw=GPRswitches(
16+
root_project=gprfor(
17+
srcdirs=[".."], mains=["main.c"], main_cargs=["-Wtrampolines"]
18+
)
19+
),
20+
covlevel="stmt",
21+
mains=["main"],
22+
extra_coverage_args=["-axcov", "--output-dir=xcov"],
23+
trace_mode="src",
24+
)
25+
26+
check_xcov_reports("xcov/*.xcov", {"xcov/main.c.xcov": {"+": {4}}})
27+
28+
thistest.result()

tools/gnatcov/instrument-c.adb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2750,6 +2750,13 @@ package body Instrument.C is
27502750
Append (Command_Line_Args, +"-x");
27512751
Append (Command_Line_Args, +To_Lower (Image (Lang)));
27522752

2753+
-- As we also pass compiler warning switches, as they can influence the
2754+
-- preprocessing through the use of the __has_warning macro, we make
2755+
-- sure to disable warnings on unknown warnings (as some warnings are
2756+
-- e.g. gcc-specific and won't be recognized by clang).
2757+
2758+
Append (Command_Line_Args, +"-Wno-unknown-warning-option");
2759+
27532760
return Command_Line_Args;
27542761
end Common_Parse_TU_Args;
27552762

0 commit comments

Comments
 (0)