[clang] [clang][Sema] Warn when macro operator mixes with outer operand due to precedence (PR #184924)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 11 07:14:12 PDT 2026
zmodem wrote:
Here's a small reproducer based on the examples above:
```
$ cat /tmp/a.c
#define ONE 1
#define TWO (1 + ONE)
int x = TWO;
$ build/bin/clang -Wmacro-mixed-operator -c /tmp/a.c
/tmp/a.c:3:9: warning: operator '+' in macro expansion has operand outside the macro; operator precedence may be different than expected [-Wmacro-mixed-operator]
3 | int x = TWO;
| ^~~
/tmp/a.c:2:16: note: expanded from macro 'TWO'
2 | #define TWO (1 + ONE)
| ~ ^ ~~~
1 warning generated.
```
https://github.com/llvm/llvm-project/pull/184924
More information about the cfe-commits
mailing list