diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-03-14 00:03:48 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-03-14 00:03:48 +0000 |
commit | 69bd16d814fa55ea310e8bd70cc60cf116f3b684 (patch) | |
tree | 6daa4f70d5d98c7e886492399bbb4540fe8d1e57 /clang/lib/Sema/SemaTemplate.cpp | |
parent | 638e530509cee042b98ea420963dcf4cbeafd526 (diff) | |
download | bcm5719-llvm-69bd16d814fa55ea310e8bd70cc60cf116f3b684.tar.gz bcm5719-llvm-69bd16d814fa55ea310e8bd70cc60cf116f3b684.zip |
Make sure that the canonical representation of integral template arguments uses the bitwidth and signedness of the template parameter
llvm-svn: 66990
Diffstat (limited to 'clang/lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | clang/lib/Sema/SemaTemplate.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 3780259d43b..142cc453f36 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/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))); } |