diff options
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 9 |
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))); } |