From: David Majnemer Date: Sun, 26 Jul 2015 09:02:26 +0000 (+0000) Subject: [MS Extensions] Remove support for the i128 integer literal suffix X-Git-Tag: studio-1.4~1571 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5055dfcf4af806edb117eaf00fb19a3911768bba;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 243243 --- diff --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp index aed9164..beacbc9 100644 --- a/clang/lib/Lex/LiteralSupport.cpp +++ b/clang/lib/Lex/LiteralSupport.cpp @@ -613,7 +613,7 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling, 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::NumericLiteralParser(StringRef TokSpelling, 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': diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 61f3616..12a2038 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3355,13 +3355,6 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // 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(const Token &Tok, Scope *UDLScope) { // 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 { diff --git a/clang/test/Lexer/ms-extensions.c b/clang/test/Lexer/ms-extensions.c index ebcf0f4..de7ef93 100644 --- a/clang/test/Lexer/ms-extensions.c +++ b/clang/test/Lexer/ms-extensions.c @@ -7,10 +7,6 @@ __int16 x2 = 4i16; __int32 x3 = 5i32; __int64 x5 = 0x42i64; __int64 x6 = 0x42I64; -#ifndef __SIZEOF_INT128__ -// expected-error@+2 {{__int128 is not supported on this target}} -#endif -__int64 x4 = 70000000i128; __int64 y = 0x42i64u; // expected-error {{invalid suffix}} __int64 w = 0x43ui64; diff --git a/clang/test/Sema/128bitint.c b/clang/test/Sema/128bitint.c index 6469d84..45e1cd8 100644 --- a/clang/test/Sema/128bitint.c +++ b/clang/test/Sema/128bitint.c @@ -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 diff --git a/clang/test/SemaCXX/ms_integer_suffix.cpp b/clang/test/SemaCXX/ms_integer_suffix.cpp index d65e7f4..aa2f130 100644 --- a/clang/test/SemaCXX/ms_integer_suffix.cpp +++ b/clang/test/SemaCXX/ms_integer_suffix.cpp @@ -18,6 +18,3 @@ static_assert(sizeof(0i32) == __SIZEOF_INT32__, ""); #ifdef __SIZEOF_INT64__ static_assert(sizeof(0i64) == __SIZEOF_INT64__, ""); #endif -#ifdef __SIZEOF_INT128__ -static_assert(sizeof(0i128) == __SIZEOF_INT128__, ""); -#endif