diff options
author | John McCall <rjmccall@apple.com> | 2011-07-15 07:47:58 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-07-15 07:47:58 +0000 |
commit | 4e9272de54094da012d49990acaf06553369d6ec (patch) | |
tree | d49cfd985369f34ff1934c087aba0bc8ab9f9246 /lib/Sema/SemaTemplate.cpp | |
parent | f70d12dbd49fcc25f1dfc0127217112ae76bcb8f (diff) |
Restore the C-style cast hack for enum template arguments,
which is required given the current setup for template
argument deduction substitution validation, and add a test
case to make sure we don't break it in the future.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaTemplate.cpp')
-rw-r--r-- | lib/Sema/SemaTemplate.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 2514b48de3..3ac190e1d4 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -4152,7 +4152,16 @@ Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg, else BT = T; - return Owned(IntegerLiteral::Create(Context, *Arg.getAsIntegral(), BT, Loc)); + Expr *E = IntegerLiteral::Create(Context, *Arg.getAsIntegral(), BT, Loc); + if (T->isEnumeralType()) { + // FIXME: This is a hack. We need a better way to handle substituted + // non-type template parameters. + E = CStyleCastExpr::Create(Context, T, VK_RValue, CK_IntegralCast, E, 0, + Context.getTrivialTypeSourceInfo(T, Loc), + Loc, Loc); + } + + return Owned(E); } /// \brief Match two template parameters within template parameter lists. |