This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Don't pass VLA bounds with arbitrary C++ specific trees to build_array_type (PR c++/28879)
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Jason Merrill <jason at redhat dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 19 Nov 2007 21:16:26 -0800
- Subject: Re: [C++ PATCH] Don't pass VLA bounds with arbitrary C++ specific trees to build_array_type (PR c++/28879)
- References: <20071119134118.GJ5451@devserv.devel.redhat.com>
Jakub Jelinek wrote:
> Even when TYPE_MAX_VALUE (index_type) is not value_dependent_expression_p,
> it can still contain various C++ FE tree nodes, which the middle-end won't
> be happy about. Or do I need both v_d_e_p check and the VLA check?
> Regtested on x86_64-linux.
The intent of value_dependent_expression_p is that it be called only
with integral constant expressions. It's not interesting to know
whether or not other expressions are value-dependent because, even if
they aren't, there's no need to know what there value is.
I think your change is OK. If the index is a non value-dependent
integral constant expression, we should simplify it before this point.
> @@ -531,7 +531,8 @@ build_cplus_array_type_1 (tree elt_type,
>
> if (dependent_type_p (elt_type)
> || (index_type
> - && value_dependent_expression_p (TYPE_MAX_VALUE (index_type))))
> + && processing_template_decl
> + && !TREE_CONSTANT (TYPE_MAX_VALUE (index_type))))
Since dependent_type_p can only be true when processing_template_decl,
you can micro-optimize by doing:
if (processing_template_decl
&& (dependent_type_p (elt_type)
|| (index_type && ...)))
OK with that change.
--
Mark Mitchell
CodeSourcery
mark@codesourcery.com
(650) 331-3385 x713