https://bugs.llvm.org/show_bug.cgi?id=42427
Bug ID: 42427
Summary: clanc-cl with -Xclang -isystem forgets meaning of
`or`, `and`, etc.
Product: clang
Version: 8.0
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Frontend
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected]
Suppose you have two files, `main.cpp`
#include <lib.h>
int main(){}
and external library `external/include/foo.h`:
#pragma once
bool foo(int x) {
int y; // generate some warning to check whenever -isystem works
return x or x;
}
You can compile it with `clang-cl /Iexternal\include /W4 test.cpp` and it will
issue an warning about `y`.
external\include\lib.h(3,9): warning: unused variable 'y' [-Wunused-variable]
You can try to suppress it by adding `-Xclang -isystemexternal\include`, but it
will lead to strange error:
> clang-cl /Iexternal\include /W4 test.cpp -Xclang -isystemexternal\include
In file included from test.cpp:1:
external\include\lib.h(4,13): error: expected ';' after return statement
return x or x;
^
1 error generated.
It turns out that alternative tokens are breaking compilation (only) for
headers which are under `-isystem` flagged directories.
`or` in main.cpp always compiles.
I've also tested `and` and `bitand` out of
https://en.cppreference.com/w/cpp/language/operator_alternative, same result.
You can work it around with preprocessor "-Dor=||":
> clang-cl /Iexternal\include /W4 test.cpp -Xclang -isystemexternal\include
> "-Dor=||"
PS. I hope I've tagged this issue correctly to frontend category.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs