-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Closed
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer
Description
Consider:
$ cat -n /tmp/a.c
1 #include <stdio.h>
2
3 void f(int x) {
4 printf("%f",
5 x);
6 }
$ build/bin/clang -c /tmp/a.c
/tmp/a.c:5:10: warning: format specifies type 'double' but the argument has type 'int' [-Wformat]
5 | printf("%f",
| ~~
| %d
6 | x);
| ^
1 warning generated.
The diag location of a.c:5:10
is correct: it points to the x
which is the argument in question.
However, the printed line numbers make it look like the printf
starts on line 5 and the x
is on line 6, which is not the case.
With -fno-diagnostics-show-line-numbers
it looks correct:
$ build/bin/clang -c /tmp/a.c -fno-diagnostics-show-line-numbers
/tmp/a.c:5:10: warning: format specifies type 'double' but the argument has type 'int' [-Wformat]
printf("%f",
~~
%d
x);
^
1 warning generated.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzer