[PATCH] Permit the "if" literal suffix with Microsoft extensions enabled.
Aaron Ballman
aaron at aaronballman.com
Thu May 29 15:41:00 PDT 2014
I can't find any mention on MSDN of this suffix being supported -- and
pasting your test case into MSVC 2013 yields compile errors about a
bad suffix on a number, and __complex being unknown. Can you point me
to some documentation on this feature?
Thanks!
~Aaron
On Thu, May 29, 2014 at 6:34 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:
> Hi rsmith,
>
> http://reviews.llvm.org/D3963
>
> Files:
> lib/Lex/LiteralSupport.cpp
> test/Lexer/ms-extensions.c
>
> Index: lib/Lex/LiteralSupport.cpp
> ===================================================================
> --- lib/Lex/LiteralSupport.cpp
> +++ lib/Lex/LiteralSupport.cpp
> @@ -606,16 +606,18 @@
> case 'i':
> case 'I':
> if (PP.getLangOpts().MicrosoftExt) {
> - if (isFPConstant || isLong || isLongLong) break;
> + if (isLong || isLongLong) break;
>
> // Allow i8, i16, i32, i64, and i128.
> if (s + 1 != ThisTokEnd) {
> switch (s[1]) {
> case '8':
> + if (isFPConstant) break;
> s += 2; // i8 suffix
> isMicrosoftInteger = true;
> break;
> case '1':
> + if (isFPConstant) break;
> if (s + 2 == ThisTokEnd) break;
> if (s[2] == '6') {
> s += 3; // i16 suffix
> @@ -630,14 +632,16 @@
> }
> break;
> case '3':
> + if (isFPConstant) break;
> if (s + 2 == ThisTokEnd) break;
> if (s[2] == '2') {
> s += 3; // i32 suffix
> isLong = true;
> isMicrosoftInteger = true;
> }
> break;
> case '6':
> + if (isFPConstant) break;
> if (s + 2 == ThisTokEnd) break;
> if (s[2] == '4') {
> s += 3; // i64 suffix
> @@ -648,7 +652,8 @@
> default:
> break;
> }
> - break;
> + if (isMicrosoftInteger)
> + break;
> }
> }
> // "i", "if", and "il" are user-defined suffixes in C++1y.
> Index: test/Lexer/ms-extensions.c
> ===================================================================
> --- test/Lexer/ms-extensions.c
> +++ test/Lexer/ms-extensions.c
> @@ -13,6 +13,10 @@
> __int64 z = 9Li64; // expected-error {{invalid suffix}}
> __int64 q = 10lli64; // expected-error {{invalid suffix}}
>
> +__complex double c1 = 1i;
> +__complex double c2 = 1.0i;
> +__complex float c3 = 1.0if;
> +
> // radar 7562363
> #define ULLONG_MAX 0xffffffffffffffffui64
> #define UINT 0xffffffffui32
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
More information about the cfe-commits
mailing list