c++: Tweaks for value_dependent_expression_p.
authorMarek Polacek <polacek@redhat.com>
Thu, 29 Oct 2020 19:19:51 +0000 (15:19 -0400)
committerMarek Polacek <polacek@redhat.com>
Tue, 3 Nov 2020 15:09:53 +0000 (10:09 -0500)
commitc2856ceec2e7542fe9b0bf104afeeeeb57d6996d
tree028f74c4d0f6294d8f0d52ae0fed7a136fda09a9
parentf620e64a6f13371b95be5b17abba0acf15bf7cae
c++: Tweaks for value_dependent_expression_p.

We may not call value_dependent_expression_p on expressions that are
not potential constant expressions, otherwise value_d could crash,
as I saw recently (in C++98).  So beef up the checking in i_d_e_p.

This revealed a curious issue: when we have __PRETTY_FUNCTION__ in
a template function, we set its DECL_VALUE_EXPR to error_mark_node
(cp_make_fname_decl), so potential_c_e returns false when it gets it,
but value_dependent_expression_p handles it specially and says true.
This broke lambda-generic-pretty1.C.  So take care of that.

And then also tweak uses_template_parms.

gcc/cp/ChangeLog:

* constexpr.c (potential_constant_expression_1): Treat
__PRETTY_FUNCTION__ inside a template function as
potentially-constant.
* pt.c (uses_template_parms): Call
instantiation_dependent_expression_p instead of
value_dependent_expression_p.
(instantiation_dependent_expression_p): Check
potential_constant_expression before calling
value_dependent_expression_p.
gcc/cp/constexpr.c
gcc/cp/pt.c