diff options
author | Stephen Canon <scanon@apple.com> | 2012-05-03 22:49:43 +0000 |
---|---|---|
committer | Stephen Canon <scanon@apple.com> | 2012-05-03 22:49:43 +0000 |
commit | b9e05f1b326996f3a46b6e2c66050e77bed0e223 (patch) | |
tree | 245fba5cca9ffd4f1e5f548d0dd3c22a6012fcf9 /lib/Sema/SemaExpr.cpp | |
parent | 44727629b766bf34bc2299c40f5ee8e4c7a71391 (diff) |
Add support for full-width 128-bit integer literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156123 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index aaf579eda6..90435aace7 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2648,7 +2648,12 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { diag::warn_cxx98_compat_longlong : diag::ext_longlong); // Get the value in the widest-possible width. - llvm::APInt ResultVal(Context.getTargetInfo().getIntMaxTWidth(), 0); + 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) + MaxWidth = 128; + llvm::APInt ResultVal(MaxWidth, 0); if (Literal.GetIntegerValue(ResultVal)) { // If this value didn't fit into uintmax_t, warn and force to ull. @@ -2696,7 +2701,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { } } - // Finally, check long long if needed. + // Check long long if needed. if (Ty.isNull()) { unsigned LongLongSize = Context.getTargetInfo().getLongLongWidth(); @@ -2713,6 +2718,16 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { Width = LongLongSize; } } + + // 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 (Literal.isUnsigned) + Ty = Context.UnsignedInt128Ty; + else + Ty = Context.Int128Ty; + Width = 128; + } // If we still couldn't decide a type, we probably have something that // does not fit in a signed long long, but has no U suffix. |