<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63963>63963</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
-Wconstant-logical-operand should not fire for expressions involving macros
</td>
</tr>
<tr>
<th>Labels</th>
<td>
quality-of-implementation,
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
AaronBallman
</td>
</tr>
</table>
<pre>
Clang currently issues this diagnostic when the constant in question is a macro, as in ([live example](https://godbolt.org/z/M13cx7hPY)):
```
#ifndef X
#define X 0
#endif
#ifndef Y
#define Y 2
#endif
bool foo() {
return X || Y;
}
```
I think any use of a macro should suppress the diagnostic on the assumption that the macro value is constant for one configuration but may not be constant in all configurations. However, I can also see why we might want to still diagnose macro uses, such as cases like:
```
void func(int error) {
if (ENOMEM || error == 12)
...
}
```
where the user could have forgotten to add `error ==` to the expression. So it might be that we want to split this off into separate diagnostic groups.
Relates to discussion in https://reviews.llvm.org/D142609
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8lM2O4zYMx59GvhAJHDm244MPM8kG3cO2RXvozJG2aVtdWfTqI5n06Qs5yXyhW8CAIZEUpf-PJDqnBkNUi_xR5IcEgx_Z1g9o2Tyi1hOapOHuUu81mgHaYC0Zry-gnAvkwI_KQadwMOy8auE8kgE_ErRsnEfjQRn4Ech5xQaUA4QJW8tC7gFdNAq5E_mjVicCesFp1iTyg5C70fvZiexByKOQx4G7hrVfsx2EPP4j5PHbJmtfyvH3ZyGr-GUPIj2I9EEU6e27LmWmetNRD0-vGx31yhA8wZsPmU71t9WnuOfPcc8gfx7XMGvomeOzZAWifLzuA1jywRp4AlHuRbmHZ5HdbKI8_Ofdv0Z5zXdAc4HgCLi_ywdu5KA7cGGeLTm3SP4OA18hoHNhmhfp_Yh-2bvGn1AHijxeOfVsgc0CrldDsLiENcHDhBcw7KH5SBW1_ujs1vALn-lEN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