Skip to content

Commit a90ea38

Browse files
committed
[Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.
Summary: Previously, the -fdollars-in-identifiers flag allows the '$' symbol to be used in an identifier but the universal character name equivalent '\u0024' is not allowed. This patch changes this, so that \u0024 is valid in identifiers. Reviewers: rsmith, jordan_rose Reviewed By: rsmith Subscribers: dexonsmith, simoncook, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71758
1 parent ca6f616 commit a90ea38

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

clang/lib/Lex/Lexer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,8 @@ void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
14311431
static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
14321432
if (LangOpts.AsmPreprocessor) {
14331433
return false;
1434+
} else if (LangOpts.DollarIdents && '$' == C) {
1435+
return true;
14341436
} else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
14351437
static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
14361438
C11AllowedIDCharRanges);

clang/test/Preprocessor/ucn-pp-identifier.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
#define \U10000000 // expected-error {{macro name must be an identifier}}
2929
#define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}}
3030

31-
// FIXME: Not clear what our behavior should be here; \u0024 is "$".
32-
#define a\u0024 // expected-warning {{whitespace}}
31+
#define a\u0024
3332

3433
#if \u0110 // expected-warning {{is not defined, evaluates to 0}}
3534
#endif

0 commit comments

Comments
 (0)