<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - clanc-cl with -Xclang -isystem forgets meaning of `or`, `and`, etc."
href="https://bugs.llvm.org/show_bug.cgi?id=42427">42427</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>clanc-cl with -Xclang -isystem forgets meaning of `or`, `and`, etc.
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>8.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Frontend
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>artur.ryt@r2software.pl
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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:
<span class="quote">> clang-cl /Iexternal\include /W4 test.cpp -Xclang -isystemexternal\include</span >
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
<a href="https://en.cppreference.com/w/cpp/language/operator_alternative">https://en.cppreference.com/w/cpp/language/operator_alternative</a>, same result.
You can work it around with preprocessor "-Dor=||":
<span class="quote">> clang-cl /Iexternal\include /W4 test.cpp -Xclang -isystemexternal\include "-Dor=||"</span >
PS. I hope I've tagged this issue correctly to frontend category.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>