[clang] Disable -fdollars-in-identifiers by default (PR #135407)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 30 12:40:55 PDT 2025


zygoloid wrote:

> This will indeed break building the Linux kernel for x86_64 at least in my brief test
[...]
> ```
> In file included from arch/x86/kernel/acpi/wakeup_64.S:11:
> arch/x86/include/asm/nospec-branch.h:80:7: warning: '$' in identifier; did you mean to enable '-fdollars-in-identifiers'? [-Wdollar-in-identifier]
>    80 |         movq    $-1, PER_CPU_VAR(__x86_call_depth);
>       |                 ^
> ```

Should we really be warning here? While this would lex as a `$` identifier under `-fdollars-in-identifiers` and as a `tok::unknown` otherwise, that difference really doesn't matter in ASM preprocessing unless `$` itself is defined as a macro name. Is it feasible to suppress the warning except in that case?

Eg, in asm preprocessing mode, could we instead warn only if `#define` is followed by a `$` token, or `#define <macro name>` is followed by a `$` token with no leading whitespace?

https://github.com/llvm/llvm-project/pull/135407


More information about the cfe-commits mailing list