[C++ PATCH] [PR/12573] Handle COMPONENT_REFs in value_dependent_expression_p (mainline regression)
Mark Mitchell
mark@codesourcery.com
Mon Dec 15 05:35:00 GMT 2003
On Mon, 2003-12-01 at 21:03, Jason Merrill wrote:
> On Tue, 25 Nov 2003 18:38:34 +0100, "Giovanni Bajo" <giovannibajo@libero.it> wrote:
>
> > BTW, COMPONENT_REF internal documentation says that the second operand of a
> > COMPONENT_REF is always a FIELD_DECL, whilst it can be an IDENTIFIER_NODE (or a
> > SCOPE_REF too, I think). Do we need a patch for documentation?
>
> Quote:
>
> This documentation describes the use of these nodes in non-template
> functions (including instantiations of template functions). In template
> functions, the same nodes are used, but sometimes in slightly different
> ways.
>
> Updating the documentation to also describe usage in templates would be
> welcome, but would need to cover more than just COMPONENT_REF.
>
> > + if (TREE_CODE (expression) == COMPONENT_REF)
> > + return value_dependent_expression_p (TREE_OPERAND (expression, 0)) ||
> > + value_dependent_expression_p (TREE_OPERAND (expression, 1));
Actually, I'm confused by this patch and I think it -- and the previous
one dealing with INDIRECT_REF -- are dubious.
The term "value-dependent expression" only applies to
constant-expressions.
A COMPONENT_REF is never a constant-expression. So, if we ever get here
with a COMPONENT_REF, we should just return "false", not recur.
But, really, we shouldn't be calling value_dependent_expression_p for
things that aren't constant-expressions.
I suspect that the real problem is that the call to
cp_parser_fold_non_dependent_expr in cp_parser_template_argument is not
guarded by non_constant_p in the same way that the call in
cp_parser_direct_declarator is so guarded.
Would you please try making that change and see if that fixes the
problem?
--
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC
More information about the Gcc-patches
mailing list