aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaTemplate.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-14 00:03:48 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-14 00:03:48 +0000
commit5b0f752655cc94b970113235110b56a722eb40d4 (patch)
tree1e3c7b628d2b85c553b80d672deb42f570f3de23 /lib/Sema/SemaTemplate.cpp
parentbc736fceca6f0bca31d16003a7587857190408fb (diff)
Make sure that the canonical representation of integral template arguments uses the bitwidth and signedness of the template parameter
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66990 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r--lib/Sema/SemaTemplate.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 3780259d43..142cc453f3 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1283,11 +1283,12 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
return false;
}
- llvm::APInt CanonicalArg(Context.getTypeSize(IntegerType), 0,
- IntegerType->isSignedIntegerType());
- CanonicalArg = Value;
+ unsigned ExpectedBits = Context.getTypeSize(IntegerType);
+ if (Value.getBitWidth() != ExpectedBits)
+ Value.extOrTrunc(ExpectedBits);
+ Value.setIsSigned(IntegerType->isSignedIntegerType());
- Converted->push_back(TemplateArgument(StartLoc, CanonicalArg,
+ Converted->push_back(TemplateArgument(StartLoc, Value,
Context.getCanonicalType(IntegerType)));
}