summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2014-06-21 00:51:59 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2014-06-21 00:51:59 +0000
commit252cbe25cb7e02df422cc9f4ac0fdf235c6b2cd8 (patch)
tree5fbae2e7f28d673555192a2f9b87c40e2772bf63 /clang/lib/Sema/SemaExpr.cpp
parentf105f588b31b4384bb48f528784cb05ae0eec060 (diff)
downloadbcm5719-llvm-252cbe25cb7e02df422cc9f4ac0fdf235c6b2cd8.tar.gz
bcm5719-llvm-252cbe25cb7e02df422cc9f4ac0fdf235c6b2cd8.zip
Lex: Use the correct types for MS integer suffixes
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: 211426
Diffstat (limited to 'clang/lib/Sema/SemaExpr.cpp')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2654c390ccf..69cc8dc2fd1 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 && MaxWidth < 128 &&
Context.getTargetInfo().hasInt128Type())
MaxWidth = 128;
llvm::APInt ResultVal(MaxWidth, 0);
@@ -3211,7 +3211,18 @@ 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) {
+ Width = Literal.MicrosoftInteger;
+ if (Width < 128)
+ Ty = Context.getIntTypeForBitwidth(Width,
+ /*Signed=*/!Literal.isUnsigned);
+ else
+ Ty = Literal.isUnsigned ? Context.UnsignedInt128Ty : Context.Int128Ty;
+ }
+
+ if (Ty.isNull() && !Literal.isLong && !Literal.isLongLong) {
// Are int/unsigned possibilities?
unsigned IntSize = Context.getTargetInfo().getIntWidth();
@@ -3258,17 +3269,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.
OpenPOWER on IntegriCloud