Open llvmbot opened 9 years ago
Indeed you're right guys. Would be nice if it was documented, though
I think that the better title would be that -Wno-error
is position dependent on the command line while -Werror
is not. The important part is whether the diagnostic is an error or a warning. With the example:
int main() {
int a;
return 0;
}
$ clang main.cpp -Wunused-variable
This gives an unused variable warning.
$ clang main.cpp -Werror -Wunused-variable
$ clang main.cpp -Wunused-variable -Werror
Both of these give an unused variable error. -Werror
does not change behavior based on position.
$ clang main.cpp -Werror -Wno-error=unused-variable -Wunused-variable
$ clang main.cpp -Werror -Wunused-variable -Wno-error=unused-variable
The first gives an error while the second gives an warning. This means that -Wno-error=*
is position dependent. (GCC will issue warnings for both of these lines.)
-Werror
does not interact or depend on the warnings on the command line.
-Wno-error=warning
does depend on its relative position to -Wwarning
.
W options are processed left-to-right. Consider:
clang++ -Wunused-variable -Wno-unused-variable main.cpp # no warning
clang++ -Wno-unused-variable -Wunused-variable main.cpp # warning
The first line happens to give same as the default behavior for that warning, but it's immaterial. The point is that "last one wins"
So this a matter of opinion that -Wall
should be interpreted first, when really it is just like any other -Wthing
, but is shorthand for "all the things"
@llvm/issue-subscribers-clang-driver
Author: None (llvmbot)
Extended Description
Here is a small example
I compile it with
And I have the expected warning. Now If I compile with:
It triggers an error, so it seems like the position of
Wall
changes the behavior, which I think is not expected.http://stackoverflow.com/questions/31855216/clang-w-flag-order