summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-18 02:12:44 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-18 02:12:44 +0000
commit9543c40df14a51e2091bcf852588c087b72d4afa (patch)
treed5c92d9019764cf3eb3fd804cbb79fe191b5d9fc /clang/lib
parent43e7f31f11ab8a8ce941a720c8198c9094bea4ea (diff)
downloadbcm5719-llvm-9543c40df14a51e2091bcf852588c087b72d4afa.tar.gz
bcm5719-llvm-9543c40df14a51e2091bcf852588c087b72d4afa.zip
When we're creating an expression for an integral template argument of
enumeration type, we were generating an integer literal implicitly casted to the appropriate enumeration type. However, later checks on that expression would strip the implicit cast. This commit tweaks the lame hack, by creating an explicit cast instead of an implicit cast. The right answer is to introduce a SubstNonTypeTemplateParmExpr expression that acts like the substituted result. I'll investigate that soon. llvm-svn: 125818
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaTemplate.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 88ba3f9a885..12ed3732e71 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -3707,8 +3707,15 @@ Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
BT = T;
Expr *E = IntegerLiteral::Create(Context, *Arg.getAsIntegral(), BT, Loc);
- ImpCastExprToType(E, T, CK_IntegralCast);
-
+ 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);
}
OpenPOWER on IntegriCloud