[clang] [clang] Fix handling of asm string literals (PR #169803)

Abhina Sree via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 7 07:58:57 PDT 2026


abhina-sree wrote:

> There seems to be no Sema test for any error cases.
> 
> For example, the diagnostic for the following (which _should not_ refer to the "literal encoding"):
> 
> ```c++
> long inline_asm(long a, long b) {
>   asm("\tLGR %0, %[\N{LATIN CAPITAL LETTER I WITH DOT ABOVE}]\n"
>   : "=r"(a)
>   : [\N{LATIN CAPITAL LETTER I WITH DOT ABOVE}] "r"(b)
>   );
> }
> ```

I've now added this testcase and made the diagnostic message generic so it can be used for both asm and literal encodings.

I

> > So if getfoo() is called anywhere else it will be in the literal encoding and match the asm string as well.
> 
> The case that is not tested is the one where a string that is "physically present" in the inline asm is passed to a constexpr function to produce the asm string. It may be mildly surprising that numeric escape sequences don't work the same inside the parentheses for the constant expression.

I've expanded systemz-charset.cpp testcase to include this as well

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


More information about the cfe-commits mailing list