summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorScott Egerton <scott.egerton@embecosm.com>2020-01-15 11:28:55 +0000
committerScott Egerton <scott.egerton@embecosm.com>2020-01-15 11:28:57 +0000
commita90ea386981f4fa3c7cb7f62c6900069764b05a8 (patch)
treeb125c624421790750335c00733eb8e3c12641873 /clang
parentca6f616532780b236556fc129cda3243d31cb01a (diff)
downloadbcm5719-llvm-a90ea386981f4fa3c7cb7f62c6900069764b05a8.tar.gz
bcm5719-llvm-a90ea386981f4fa3c7cb7f62c6900069764b05a8.zip
[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
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/Lexer.cpp2
-rw-r--r--clang/test/Preprocessor/ucn-pp-identifier.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 902b1739791..648bda27057 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@ void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
if (LangOpts.AsmPreprocessor) {
return false;
+ } else if (LangOpts.DollarIdents && '$' == C) {
+ return true;
} else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
C11AllowedIDCharRanges);
diff --git a/clang/test/Preprocessor/ucn-pp-identifier.c b/clang/test/Preprocessor/ucn-pp-identifier.c
index f045e38e94a..0929412a76e 100644
--- a/clang/test/Preprocessor/ucn-pp-identifier.c
+++ b/clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
#define \U10000000 // expected-error {{macro name must be an identifier}}
#define \u0061 // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}}
-// FIXME: Not clear what our behavior should be here; \u0024 is "$".
-#define a\u0024 // expected-warning {{whitespace}}
+#define a\u0024
#if \u0110 // expected-warning {{is not defined, evaluates to 0}}
#endif
OpenPOWER on IntegriCloud