-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang with -pedantic
issues -Wgnu-line-marker
that it wrote itself in -frewrite-includes
output
#63284
Comments
@llvm/issue-subscribers-clang-frontend |
We previously failed to issue an extension warning for GNU line markers, but that was fixed in Clang 15. I'm not certain this is a bug so much as a feature request. You're preprocessing to a file (no diagnostics from that step) and then running the preprocessed code back through the compiler (that's when you get the diagnostic). Clang does not support |
But I am not sure what I am requesting here, if anything at all. I think it's surprising that Clang warns about things it wrote itself so I wanted to report it and also have a place to refer to from our code which hacks around it (for now we just forcefully disable this warning when compiling partially preprocessed sources). From my POV the correct fix would be to write some marker to the output of |
That's a really good point! Oofda...
I think it's good that you brought the topic up, there's some interesting nuance here, so thank you!
That runs into the problem of being an extension as well, and Ooh, here's a thought.
to disable pedantic diagnostics for the line markers for rewritten includes. This seems to already work today: https://godbolt.org/z/78MGG656z That said, if there's a ton of line markers, it might cause sufficient compile time overhead to be a problem. |
Haven't thought of $ cat <<EOF >test.c
#include <stdlib.h>
# 1 "test.y"
EOF
$ clang -pedantic -E -frewrite-includes -o test.i test.c
test.c:2:5: warning: this style of line directive is a GNU extension [-Wgnu-line-marker]
# 1 "test.y"
^
$ cat <<EOF >test1.i
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wgnu-line-marker"
EOF
$ cat test.i >>test1.i
$ cat <<EOF >>test1.i
#pragma clang diagnostic pop
EOF
$ clang -pedantic -c test1.i Note that I believe we want to ignore |
We do need to think about what diagnostic to disable, but my thinking is that disabling |
Just noting that we're also seeing this issue in AMD's fork for the ROCm stack: |
Clang issues the
"this style of line directive is a GNU extension"
warning for line directives that it writes itself in the output produced with-frewrite-includes
. For example:This appears to be new behavior starting from Clang 15.
The text was updated successfully, but these errors were encountered: