llvm-project/clang/test/Preprocessor/macro_paste_identifier_ucn.c
yronglin 8b0d112478
[Clang][Preprocessor] Expand UCNs in macro concatenation (#145351)
Fixs https://github.com/llvm/llvm-project/issues/145240.

The UCN in preprocessor pasted identifier not resolved to unicode, it
may cause the following issue:
```c
#define CAT(a,b) a##b

char foo\u00b5;
char*p = &CAT(foo, \u00b5); // error: use of undeclared identifier 'foo\u00b5'
```
The real identifier after paste is `fooµ`. This PR fix this issue in
`TokenLexer::pasteTokens`, if there has any UCN in pasting tokens, the
final pasted token should have a Token::HasUCN flag. Then
`Preprocessor::LookUpIdentifierInfo` will expand UCNs in this token.

Signed-off-by: yronglin <yronglin777@gmail.com>
2025-06-25 00:56:01 +08:00

11 lines
251 B
C

// RUN: %clang_cc1 -fms-extensions %s -verify
// RUN: %clang_cc1 -E -fms-extensions %s | FileCheck %s
// expected-no-diagnostics
#define CAT(a,b) a##b
char foo\u00b5;
char*p = &CAT(foo, \u00b5);
// CHECK: char fooµ;
// CHECK-NEXT: char*p = &fooµ;