Issue 60958
Summary Clang -E incorrect -Wunicode diagnostic
Labels new issue
Assignees
Reporter andyhhp
    Discovered entirely accidentally while trying to work around #60792

Given
```
$ cat hdr.h 
.macro test uniq
    mov $\uniq, %eax
.endm

$ cat src.c
#include "hdr.h"

$ clang-15 -E src.c -o out.i
In file included from src.c:1:
./hdr.h:2:11: warning: \u used with no following hex digits; treating as '\' followed by identifier [-Wunicode]
    mov $\uniq, %eax
          ^
```

But there's are no strings here, and no context AFAICT where it would be legitimate to interpret `\u` as a unicode escape in the first place.

But if I rename src.c to src.S, it behaves differently
```
$ cp src.c src.S
$ clang-15 -E src.S -o out.i
$
```
and completes with no complaints.

Clearly this diagnostic is conditional on the file extension (which isn't great behaviour to start with), but I don't think it's a legitimate diagnostic for `*.c` files in the first place either.

It's worth saying for completeness that macros written entirely at the C level work fine, because they have to be written as 
```
asm (".macro test uniq; mov $\\uniq, %eax; .endm");
```
with the backslash needing to be escaped, rather than the u.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to