diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-06-21 18:46:07 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-06-21 18:46:07 +0000 |
commit | 65a407c2ceabcb6ff8f62c45ff8de2b473823e2c (patch) | |
tree | f28c8426cf8ea77f4f185b331ba104819bf0899b /clang/lib/Sema/SemaExpr.cpp | |
parent | 30d7731032d7c841b1dfa9ad0900d8ae987fab11 (diff) | |
download | bcm5719-llvm-65a407c2ceabcb6ff8f62c45ff8de2b473823e2c.tar.gz bcm5719-llvm-65a407c2ceabcb6ff8f62c45ff8de2b473823e2c.zip |
Lex: Use the correct types for MS integer suffixes
Something went wrong with r211426, it is an older version of this code
and should not have been committed. It was reverted with r211434.
Original commit message:
We didn't properly implement support for the sized integer suffixes.
Suffixes like i16 were essentially ignored instead of mapping them to
the appropriately sized integer type.
This fixes PR20008.
Differential Revision: http://reviews.llvm.org/D4132
llvm-svn: 211441
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 2654c390ccf..bda80cd205d 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3190,7 +3190,7 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // may be wider than [u]intmax_t. // FIXME: Actually, they don't. We seem to have accidentally invented the // i128 suffix. - if (Literal.isMicrosoftInteger && MaxWidth < 128 && + if (Literal.MicrosoftInteger == 128 && MaxWidth < 128 && Context.getTargetInfo().hasInt128Type()) MaxWidth = 128; llvm::APInt ResultVal(MaxWidth, 0); @@ -3211,7 +3211,22 @@ ExprResult Sema::ActOnNumericConstant(const Token &Tok, Scope *UDLScope) { // Check from smallest to largest, picking the smallest type we can. unsigned Width = 0; - if (!Literal.isLong && !Literal.isLongLong) { + + // 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 { + Width = Literal.MicrosoftInteger; + Ty = Context.getIntTypeForBitwidth(Width, + /*Signed=*/!Literal.isUnsigned); + } + } + + if (Ty.isNull() && !Literal.isLong && !Literal.isLongLong) { // Are int/unsigned possibilities? unsigned IntSize = Context.getTargetInfo().getIntWidth(); @@ -3258,17 +3273,6 @@ 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 && - Context.getTargetInfo().hasInt128Type()) { - 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. |