[PATCH] Fix parsing comma in default arguments.
Olivier Goffart
ogoffart at kde.org
Thu Jun 13 16:17:22 PDT 2013
On Thursday 13 June 2013 13:52:47 Richard Smith wrote:
> That's not really acceptable, if it can lead to rejecting valid code
> that we accept now (such as your next example).
Ok, the new attached patch fixes that issue.
I'm now quite happy which what (i think) we cover.
It even report good errors when one miss a default argument (on the right
line)
What is still not working is this:
template <int, int =0> struct p { const static int w = 0; };
struct T {
int i = p<0, p<a<b>::w >::w, p<0>::*j;
static const int a = 1, b = 2;
};
because a and b are declare after, and the TryAnnotateCXXScopeToken will
display error as a and b are not defined yet.
But clang did not accept this code before. And gcc also seems to have a bug
there.
> > Also a template argument can contains = for example in this case:
> > struct S {constexpr S(){}; constexpr int operator=(int) const {return
> > 5;}};
> > template <int> struct A {};
> > constexpr S s;
> > A<s=4> a;
>
> This is ill-formed.
Why?
the operator= is a constexpr
>
> > But, while GCC accept this code, clang currently reject it. But that's
> > another bug
>
> That's a GCC bug. A non-type template argument has to be a
> constant-expression, which is a conditional-expression, and thus
> cannot be an assignment-expression.
but an assignment-expression do not require to semanticly an assignement.
But it should not happen in sensible code
--
Olivier
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-parsing-comma-in-default-argument.patch
Type: text/x-patch
Size: 13258 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130614/e393eebf/attachment.bin>
More information about the cfe-commits
mailing list