r243243 - [MS Extensions] Remove support for the i128 integer literal suffix

Saleem Abdulrasool compnerd at compnerd.org
Sun Jul 26 09:58:03 PDT 2015


On Sun, Jul 26, 2015 at 2:02 AM, David Majnemer <david.majnemer at gmail.com>
wrote:

> Author: majnemer
> Date: Sun Jul 26 04:02:26 2015
> New Revision: 243243
>
> URL: http://llvm.org/viewvc/llvm-project?rev=243243&view=rev
> Log:
> [MS Extensions] Remove support for the i128 integer literal suffix
>
> There is currently no support in MSVC for using i128 as an integer
> literal suffix.  In fact, there appears to be no evidence that they have
> ever supported this feature in any of their compilers.  This was an over
> generalization of their actual feature and is a nasty source of bugs.
> Why is it a source of bugs?  Because most code in clang expects that
> evaluation of an integer constant expression won't give them something
> that 'long long' can't represent.  Instead of providing a meaningful
> feature, i128 gives us cute ways of exploding the compiler.
>

https://msdn.microsoft.com/en-us/library/cc953fe1.aspx claims otherwise.

Under Microsoft Specific types:

*__int* *n*

8, 16, 32, 64, or 128 bits depending on the value of *n**. __int**n* is
Microsoft-specific.

Modified:
>     cfe/trunk/lib/Lex/LiteralSupport.cpp
>     cfe/trunk/lib/Sema/SemaExpr.cpp
>     cfe/trunk/test/Lexer/ms-extensions.c
>     cfe/trunk/test/Sema/128bitint.c
>     cfe/trunk/test/SemaCXX/ms_integer_suffix.cpp
>
> Modified: cfe/trunk/lib/Lex/LiteralSupport.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/LiteralSupport.cpp?rev=243243&r1=243242&r2=243243&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Lex/LiteralSupport.cpp (original)
> +++ cfe/trunk/lib/Lex/LiteralSupport.cpp Sun Jul 26 04:02:26 2015
> @@ -613,7 +613,7 @@ NumericLiteralParser::NumericLiteralPars
>            break;
>
>          if (!isFPConstant) {
> -          // Allow i8, i16, i32, i64, and i128.
> +          // Allow i8, i16, i32, and i64.
>            switch (s[1]) {
>            case '8':
>              s += 2; // i8 suffix
> @@ -623,9 +623,6 @@ NumericLiteralParser::NumericLiteralPars
>              if (s[2] == '6') {
>                s += 3; // i16 suffix
>                MicrosoftInteger = 16;
> -            } else if (s[2] == '2' && s[3] == '8') {
> -              s += 4; // i128 suffix
> -              MicrosoftInteger = 128;
>              }
>              break;
>            case '3':
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=243243&r1=243242&r2=243243&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Sun Jul 26 04:02:26 2015
> @@ -3355,13 +3355,6 @@ ExprResult Sema::ActOnNumericConstant(co
>
>      // Get the value in the widest-possible width.
>      unsigned MaxWidth = Context.getTargetInfo().getIntMaxTWidth();
> -    // The microsoft literal suffix extensions support 128-bit literals,
> which
> -    // may be wider than [u]intmax_t.
> -    // FIXME: Actually, they don't. We seem to have accidentally invented
> the
> -    //        i128 suffix.
> -    if (Literal.MicrosoftInteger == 128 && MaxWidth < 128 &&
> -        Context.getTargetInfo().hasInt128Type())
> -      MaxWidth = 128;
>      llvm::APInt ResultVal(MaxWidth, 0);
>
>      if (Literal.GetIntegerValue(ResultVal)) {
> @@ -3384,12 +3377,7 @@ ExprResult Sema::ActOnNumericConstant(co
>
>        // Microsoft specific integer suffixes are explicitly sized.
>        if (Literal.MicrosoftInteger) {
> -        if (Literal.MicrosoftInteger > MaxWidth) {
> -          // If this target doesn't support __int128, error and force to
> ull.
> -          Diag(Tok.getLocation(), diag::err_int128_unsupported);
> -          Width = MaxWidth;
> -          Ty = Context.getIntMaxType();
> -        } else if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
> +        if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
>            Width = 8;
>            Ty = Context.CharTy;
>          } else {
>
> Modified: cfe/trunk/test/Lexer/ms-extensions.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/ms-extensions.c?rev=243243&r1=243242&r2=243243&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Lexer/ms-extensions.c (original)
> +++ cfe/trunk/test/Lexer/ms-extensions.c Sun Jul 26 04:02:26 2015
> @@ -7,10 +7,6 @@ __int16 x2 = 4i16;
>  __int32 x3 = 5i32;
>  __int64 x5 = 0x42i64;
>  __int64 x6 = 0x42I64;
> -#ifndef __SIZEOF_INT128__
> -// expected-error at +2 {{__int128 is not supported on this target}}
> -#endif
> -__int64 x4 = 70000000i128;
>
>  __int64 y = 0x42i64u;  // expected-error {{invalid suffix}}
>  __int64 w = 0x43ui64;
>
> Modified: cfe/trunk/test/Sema/128bitint.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/128bitint.c?rev=243243&r1=243242&r2=243243&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/Sema/128bitint.c (original)
> +++ cfe/trunk/test/Sema/128bitint.c Sun Jul 26 04:02:26 2015
> @@ -1,5 +1,5 @@
> -// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9
> -fms-extensions %s -DHAVE
> -// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu
> -fms-extensions %s -DHAVE_NOT
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s
> -DHAVE
> +// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-gnu %s
> -DHAVE_NOT
>
>  #ifdef HAVE
>  typedef int i128 __attribute__((__mode__(TI)));
> @@ -17,28 +17,14 @@ __int128 i = (__int128)0;
>  unsigned __int128 u = (unsigned __int128)-1;
>
>  long long SignedTooBig = 123456789012345678901234567890; //
> expected-error {{integer literal is too large to be represented in any
> integer type}}
> -__int128_t Signed128 = 123456789012345678901234567890i128;
> -long long Signed64 = 123456789012345678901234567890i128; //
> expected-warning {{implicit conversion from '__int128' to 'long long'
> changes value from 123456789012345678901234567890 to -4362896299872285998}}
>  unsigned long long UnsignedTooBig = 123456789012345678901234567890; //
> expected-error {{integer literal is too large to be represented in any
> integer type}}
> -__uint128_t Unsigned128 = 123456789012345678901234567890Ui128;
> -unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; //
> expected-warning {{implicit conversion from 'unsigned __int128' to
> 'unsigned long long' changes value from 123456789012345678901234567890 to
> 14083847773837265618}}
> -
> -// Ensure we don't crash when user passes 128-bit values to type safety
> -// attributes.
> -void pointer_with_type_tag_arg_num_1(void *buf, int datatype)
> -    __attribute__(( pointer_with_type_tag(mpi,0x10000000000000001i128,1)
> )); // expected-error {{attribute parameter 2 is out of bounds}}
> -
> -void pointer_with_type_tag_arg_num_2(void *buf, int datatype)
> -    __attribute__(( pointer_with_type_tag(mpi,1,0x10000000000000001i128)
> )); // expected-error {{attribute parameter 3 is out of bounds}}
>
>  void MPI_Send(void *buf, int datatype) __attribute__((
> pointer_with_type_tag(mpi,1,2) ));
>
> -static const __uint128_t mpi_int_wrong __attribute__((
> type_tag_for_datatype(mpi,int) )) = 0x10000000000000001i128; //
> expected-error {{'type_tag_for_datatype' attribute requires the initializer
> to be an integer constant expression that can be represented by a 64 bit
> integer}}
>  static const int mpi_int __attribute__(( type_tag_for_datatype(mpi,int)
> )) = 10;
>
>  void test(int *buf)
>  {
> -  MPI_Send(buf, 0x10000000000000001i128); // expected-warning {{implicit
> conversion from '__int128' to 'int' changes value}}
>  }
>  #else
>
>
> Modified: cfe/trunk/test/SemaCXX/ms_integer_suffix.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/ms_integer_suffix.cpp?rev=243243&r1=243242&r2=243243&view=diff
>
> ==============================================================================
> --- cfe/trunk/test/SemaCXX/ms_integer_suffix.cpp (original)
> +++ cfe/trunk/test/SemaCXX/ms_integer_suffix.cpp Sun Jul 26 04:02:26 2015
> @@ -18,6 +18,3 @@ static_assert(sizeof(0i32) == __SIZEOF_I
>  #ifdef __SIZEOF_INT64__
>  static_assert(sizeof(0i64) == __SIZEOF_INT64__, "");
>  #endif
> -#ifdef __SIZEOF_INT128__
> -static_assert(sizeof(0i128) == __SIZEOF_INT128__, "");
> -#endif
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>



-- 
Saleem Abdulrasool
compnerd (at) compnerd (dot) org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150726/d9c434bd/attachment.html>


More information about the cfe-commits mailing list