[C++ RFC / patch] PR 32674

Mark Mitchell mark@codesourcery.com
Thu Sep 6 15:02:00 GMT 2007


Paolo Carlini wrote:

> ----------------------- snip -----------------------
> class C
> {
>   static const int j = 3;
> };
> 
> template<int> class A
> {
>     static const int i;
> };
> 
> template<int N> const int A<N>::i(C::j);
> ----------------------- snip -----------------------

> as you can see, we have a SCOPE_REF in a TREE_LIST.

Thanks for working on this; I was planning to try to get to this one if
nobody else did...

Here's what I think is happening.  We use a TREE_LIST to represent an
initializer before we do very much semantic analysis.  After all, for
something like:

  S s(3, 4, 6);

we have three arguments; that turns out to be an initializer.

So, does the test case work if you say:

  ... A<N>::i = C::j;

?

If so, then when INIT is a TREE_LIST, then I think that we should
fold_non_dependent_expr each of the elements separately (instead of just
calling init = fold_non_dependent_expr).  Then, hopefully, the rest of
the routine will issue an error about:

  ... A<N>::i = (C::j, 7, 3);

for example.

I don't think it makes sense for type_dependent_expression_p and
value_dependent_expression_p to handle things that aren't expressions,
and a TREE_LIST is most definitely not an expression.

-- 
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713



More information about the Gcc-patches mailing list