]> granicus.if.org Git - clang/commitdiff
NumericLiteralParser::ParseNumberStartingWithZero(): Try to appease MSC16's miscompil...
authorNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 27 Sep 2013 04:42:28 +0000 (04:42 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Fri, 27 Sep 2013 04:42:28 +0000 (04:42 +0000)
Investigating yet. It seems msc16 miscompiles s[1] to be folded.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191485 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/LiteralSupport.cpp

index 61f1d55a0edfb536e09933da435bf654c9d298d8..17c6bb3049bcb58a67a386eaa1179463d42271ee 100644 (file)
@@ -706,8 +706,11 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
   assert(s[0] == '0' && "Invalid method call");
   s++;
 
+  int c1 = s[0];
+  int c2 = s[1];
+
   // Handle a hex number like 0x1234.
-  if ((*s == 'x' || *s == 'X') && (isHexDigit(s[1]) || s[1] == '.')) {
+  if ((c1 == 'x' || c1 == 'X') && (isHexDigit(c2) || c2 == '.')) {
     s++;
     radix = 16;
     DigitsBegin = s;
@@ -757,7 +760,7 @@ void NumericLiteralParser::ParseNumberStartingWithZero(SourceLocation TokLoc) {
   }
 
   // Handle simple binary numbers 0b01010
-  if ((*s == 'b' || *s == 'B') && (s[1] == '0' || s[1] == '1')) {
+  if ((c1 == 'b' || c1 == 'B') && (c2 == '0' || c2 == '1')) {
     // 0b101010 is a C++1y / GCC extension.
     PP.Diag(TokLoc,
             PP.getLangOpts().CPlusPlus1y