This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Don't pass VLA bounds with arbitrary C++ specific trees to build_array_type (PR c++/28879)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]