[cfe-dev] Should DiffTemplate be able to handle Integral args?
Matthew Curtis
mcurtis at codeaurora.org
Fri Oct 19 13:56:01 PDT 2012
Hello all,
I'm seeing an assert when compiling code like this:
template <int i> struct X { };
void f(X<8> x) {
X<7> y;
y = x;
}
DiffTemplate/GetExpr (in ASTDiagnostic.cpp) assumes that the non-type
args are expressions:
void DiffTemplate() {
// Handle Expressions
if (NonTypeTemplateParmDecl *DefaultNTTPD =
dyn_cast<NonTypeTemplateParmDecl>(ParamND)) {
Expr *FromExpr, *ToExpr;
GetExpr(FromIter, DefaultNTTPD, FromExpr);
GetExpr(ToIter, DefaultNTTPD, ToExpr);
}
}
void GetExpr(const TSTiterator &Iter, ) {
if (!Iter.isEnd())
ArgExpr = Iter->getAsExpr();
}
But in some cases they are integral values (e.g. Iter->getKind() ==
TemplateArgument::Integral). As a result, an assertion inside
Iter->getAsExpr() fails.
Is DiffTemplate broken or should the integral arg never have found it's
way to it?
BTW, I modified GetExpr to create an Expr from the Integral arg and that
seemed to work, but I'm not sure if that's the right thing to do.
Cheers,
Matthew C.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121019/c2976fab/attachment.html>
More information about the cfe-dev
mailing list