[cfe-commits] r90036 - in /cfe/trunk: lib/Lex/LiteralSupport.cpp test/CXX/basic/basic.link/ test/Lexer/constants-ms.c
Nuno Lopes
nunoplopes at sapo.pt
Sat Nov 28 05:37:54 PST 2009
Author: nlopes
Date: Sat Nov 28 07:37:52 2009
New Revision: 90036
URL: http://llvm.org/viewvc/llvm-project?rev=90036&view=rev
Log:
cleanup parsing of MS integer suffixes a little. this fixes PR5616
btw, I believe that isMicrosoftInteger can go away; it's not read anywhere
Added:
cfe/trunk/test/Lexer/constants-ms.c
Modified:
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/test/CXX/basic/basic.link/ (props changed)
Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=90036&r1=90035&r2=90036&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
+++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sat Nov 28 07:37:52 2009
@@ -375,46 +375,34 @@
continue; // Success.
case 'i':
if (PP.getLangOptions().Microsoft) {
+ if (isFPConstant || isUnsigned || isLong || isLongLong) break;
+
// Allow i8, i16, i32, i64, and i128.
if (s + 1 != ThisTokEnd) {
switch (s[1]) {
case '8':
s += 2; // i8 suffix
isMicrosoftInteger = true;
- continue;
+ break;
case '1':
- s += 2;
- if (s == ThisTokEnd) break;
- if (*s == '6') s++; // i16 suffix
- else if (*s == '2') {
- if (++s == ThisTokEnd) break;
- if (*s == '8') s++; // i128 suffix
+ if (s + 2 == ThisTokEnd) break;
+ if (s[2] == '6') s += 3; // i16 suffix
+ else if (s[2] == '2') {
+ if (s + 3 == ThisTokEnd) break;
+ if (s[3] == '8') s += 4; // i128 suffix
}
isMicrosoftInteger = true;
- continue;
+ break;
case '3':
- s += 2;
- if (s == ThisTokEnd) break;
- if (*s == '2') s++; // i32 suffix
+ if (s + 2 == ThisTokEnd) break;
+ if (s[2] == '2') s += 3; // i32 suffix
isMicrosoftInteger = true;
- continue;
+ break;
case '6':
- s += 2;
- if (s == ThisTokEnd) break;
- if (*s == '4') s++; // i64 suffix
+ if (s + 2 == ThisTokEnd) break;
+ if (s[2] == '4') s += 3; // i64 suffix
isMicrosoftInteger = true;
- continue;
- case 'f': // FP Suffix for "float"
- case 'F':
- if (!isFPConstant) break; // Error for integer constant.
- if (isFloat || isLong) break; // FF, LF invalid.
- isFloat = true;
- if (isImaginary) break; // Cannot be repeated.
- PP.Diag(PP.AdvanceToTokenCharacter(TokLoc, s-begin),
- diag::ext_imaginary_constant);
- isImaginary = true;
- s++;
- continue; // Success.
+ break;
default:
break;
}
Propchange: cfe/trunk/test/CXX/basic/basic.link/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Nov 28 07:37:52 2009
@@ -0,0 +1 @@
+Output
Added: cfe/trunk/test/Lexer/constants-ms.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/constants-ms.c?rev=90036&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/constants-ms.c (added)
+++ cfe/trunk/test/Lexer/constants-ms.c Sat Nov 28 07:37:52 2009
@@ -0,0 +1,12 @@
+// RUN: clang-cc -fsyntax-only -verify -fms-extensions %s
+
+__int8 x1 = 3i8;
+__int16 x2 = 4i16;
+__int32 x3 = 5i32;
+__int64 x5 = 0x42i64;
+__int64 x4 = 70000000i128;
+
+__int64 y = 0x42i64u; // expected-error {{invalid suffix}}
+__int64 w = 0x43ui64; // expected-error {{invalid suffix}}
+__int64 z = 9Li64; // expected-error {{invalid suffix}}
+__int64 q = 10lli64; // expected-error {{invalid suffix}}
More information about the cfe-commits
mailing list