[cfe-dev] Should DiffTemplate be able to handle Integral args?
Richard Trieu
rtrieu at google.com
Mon Oct 22 11:07:45 PDT 2012
On Fri, Oct 19, 2012 at 1:56 PM, Matthew Curtis <mcurtis at codeaurora.org>wrote:
> 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
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
This was reported in PR14015. I have created a patch to fixed this issue.
See the posting below on cfe-commits.
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20121008/065792.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121022/64e3ff49/attachment.html>
More information about the cfe-dev
mailing list