barannikov88 created this revision.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144100

Files:
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/Lexer/char-escapes-delimited.c


Index: clang/test/Lexer/char-escapes-delimited.c
===================================================================
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0xFFFF
   unsigned d = L'\o{37777777777}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{40000000000}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned f = L'\o{100000000000}'; // expected-error {{octal escape sequence 
out of range}}
+  unsigned g = L'\o{200000000000}'; // expected-error {{octal escape sequence 
out of range}}
 #else
   unsigned d = L'\o{177777}'; // ext-warning {{extension}} cxx2b-warning 
{{C++2b}}
   unsigned e = L'\o{200000}'; // expected-error {{octal escape sequence out of 
range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===================================================================
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
         ThisTokBuf++;
         continue;
       }
-      if (ResultChar & 0x020000000)
+      // About to shift out a digit?
+      if (ResultChar & 0xE0000000)
         Overflow = true;
 
       ResultChar <<= 3;


Index: clang/test/Lexer/char-escapes-delimited.c
===================================================================
--- clang/test/Lexer/char-escapes-delimited.c
+++ clang/test/Lexer/char-escapes-delimited.c
@@ -58,6 +58,8 @@
 #if __WCHAR_MAX__ > 0xFFFF
   unsigned d = L'\o{37777777777}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{40000000000}'; // expected-error {{octal escape sequence out of range}}
+  unsigned f = L'\o{100000000000}'; // expected-error {{octal escape sequence out of range}}
+  unsigned g = L'\o{200000000000}'; // expected-error {{octal escape sequence out of range}}
 #else
   unsigned d = L'\o{177777}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned e = L'\o{200000}'; // expected-error {{octal escape sequence out of range}}
Index: clang/lib/Lex/LiteralSupport.cpp
===================================================================
--- clang/lib/Lex/LiteralSupport.cpp
+++ clang/lib/Lex/LiteralSupport.cpp
@@ -263,7 +263,8 @@
         ThisTokBuf++;
         continue;
       }
-      if (ResultChar & 0x020000000)
+      // About to shift out a digit?
+      if (ResultChar & 0xE0000000)
         Overflow = true;
 
       ResultChar <<= 3;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to