<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121984>121984</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang doesn't suppress warnings in system headers if they are also found with -iquote
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
phst
</td>
</tr>
</table>
<pre>
https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers states that
> Warnings are suppressed when they occur in system headers. By default, an included file is treated as a system header if it is found in an include path specified by `-isystem` [...]
without further conditions on the include directories specified by `-isystem`.
Given the setup:
```
$ cat /tmp/a/a.c
#include "b.h"
$ cat /tmp/b/b.h
/* /* */
```
Both GCC and Clang agree that a warning should be generated if the header is found with `-iquote`:
```
$ gcc-14 -Wcomment -c /tmp/a/a.c -iquote /tmp/b
In file included from /tmp/a/a.c:1:
/tmp/b/b.h:1:4: warning: "/*" within comment [-Wcomment]
1 | /* /* */
$ clang -Wcomment -c /tmp/a/a.c -iquote /tmp/b
In file included from /tmp/a/a.c:1:
/tmp/b/b.h:1:4: warning: '/*' within block comment [-Wcomment]
1 | /* /* */
| ^
1 warning generated.
```
Both compilers also agree that the warning should be suppressed if the header is found with `-isystem`:
```
$ gcc-14 -Wcomment -c /tmp/a/a.c -isystem /tmp/b
$ clang -Wcomment -c /tmp/a/a.c -isystem /tmp/b
```
However, if both `-iquote` and `-isystem` is used, Clang doesn't suppress the warning, while GCC does:
```
$ gcc-14 -Wcomment -c /tmp/a/a.c -iquote /tmp/b -isystem /tmp/b
$ clang -Wcomment -c /tmp/a/a.c -iquote /tmp/b -isystem /tmp/b
In file included from /tmp/a/a.c:1:
/tmp/b/b.h:1:4: warning: '/*' within block comment [-Wcomment]
1 | /* /* */
| ^
1 warning generated.
```
My understanding (given the documentation) is that the GCC behavior is the correct one.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm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