[PATCH] D71758: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2020-01-15 Thread Scott Egerton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa90ea386981f: [Lexer] Allow UCN for dollar symbol 
\u0024 in identifiers when using… (authored by s.egerton).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71758/new/

https://reviews.llvm.org/D71758

Files:
  clang/lib/Lex/Lexer.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // 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
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions ) {
   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);


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // 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
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions ) {
   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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71758: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2019-12-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This seems reasonable to me, and matches GCC 10's behavior; `$` is not in the 
basic source character set, so encoding it with a UCN should be permitted.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71758/new/

https://reviews.llvm.org/D71758



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71758: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2019-12-20 Thread Scott Egerton via Phabricator via cfe-commits
s.egerton created this revision.
Herald added subscribers: cfe-commits, simoncook.
Herald added a project: clang.
s.egerton added reviewers: rsmith, akyrtzi, jordan_rose.
Herald added a subscriber: dexonsmith.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D71758

Files:
  clang/lib/Lex/Lexer.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // 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
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions ) {
   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);


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // 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
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions ) {
   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);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits