diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Frontend/InitPreprocessor.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/Sema.cpp | 2 | ||||
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 8 | ||||
-rw-r--r-- | lib/Sema/SemaType.cpp | 2 |
4 files changed, 11 insertions, 3 deletions
diff --git a/lib/Frontend/InitPreprocessor.cpp b/lib/Frontend/InitPreprocessor.cpp index 4bbd033f1c..7da7353278 100644 --- a/lib/Frontend/InitPreprocessor.cpp +++ b/lib/Frontend/InitPreprocessor.cpp @@ -507,6 +507,8 @@ static void InitializePredefinedMacros(const TargetInfo &TI, TI.getTypeWidth(TI.getWCharType()), TI, Builder); DefineTypeSizeof("__SIZEOF_WINT_T__", TI.getTypeWidth(TI.getWIntType()), TI, Builder); + if (TI.hasInt128Type()) + DefineTypeSizeof("__SIZEOF_INT128__", 128, TI, Builder); DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Builder); DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Builder); diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp index 13a33b785b..f9666f4832 100644 --- a/lib/Sema/Sema.cpp +++ b/lib/Sema/Sema.cpp @@ -128,7 +128,7 @@ void Sema::Initialize() { ExternalSema->InitializeSema(*this); // Initialize predefined 128-bit integer types, if needed. - if (PP.getTargetInfo().getPointerWidth(0) >= 64) { + if (PP.getTargetInfo().hasInt128Type()) { // If either of the 128-bit integer types are unavailable to name lookup, // define them now. DeclarationName Int128 = &Context.Idents.get("__int128_t"); diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 66beb34128..dd1bc0b657 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2841,7 +2841,10 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { unsigned MaxWidth = Context.getTargetInfo().getIntMaxTWidth(); // The microsoft literal suffix extensions support 128-bit literals, which // may be wider than [u]intmax_t. - if (Literal.isMicrosoftInteger && MaxWidth < 128) + // FIXME: Actually, they don't. We seem to have accidentally invented the + // i128 suffix. + if (Literal.isMicrosoftInteger && MaxWidth < 128 && + PP.getTargetInfo().hasInt128Type()) MaxWidth = 128; llvm::APInt ResultVal(MaxWidth, 0); @@ -2911,7 +2914,8 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // If it doesn't fit in unsigned long long, and we're using Microsoft // extensions, then its a 128-bit integer literal. - if (Ty.isNull() && Literal.isMicrosoftInteger) { + if (Ty.isNull() && Literal.isMicrosoftInteger && + PP.getTargetInfo().hasInt128Type()) { if (Literal.isUnsigned) Ty = Context.UnsignedInt128Ty; else diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index 4b23167951..17a6922190 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -742,6 +742,8 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { break; } case DeclSpec::TST_int128: + if (!S.PP.getTargetInfo().hasInt128Type()) + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_int128_unsupported); if (DS.getTypeSpecSign() == DeclSpec::TSS_unsigned) Result = Context.UnsignedInt128Ty; else |