On 8/1/19 3:50 PM, Marek Polacek wrote:
We started rejecting this test with r268321, whereby we process the
compound_literal in finish_compound_literal normally even in a template
if it's not instantiation-dependent. This broke with __PRETTY_FUNCTION__
in a template function, because instantiation_dependent_expression_p didn't
consider it dependent, which resulted in a bogus error later.
cp_make_fname_decl has TYPE_DEP indicating that the fname is dependent, so
I think value_dependent_expression_p needs to be fixed as below, and actually
treat such a fname as dependent.
Bootstrapped/regtested on x86_64-linux, ok for trunk and 9?
2019-08-01 Marek Polacek <pola...@redhat.com>
PR c++/91230 - wrong error with __PRETTY_FUNCTION__ and generic lambda.
* pt.c (value_dependent_expression_p): Consider __PRETTY_FUNCTION__
inside a template function value-dependent.
* g++.dg/cpp1y/lambda-generic-pretty1.C: New test.
diff --git gcc/cp/pt.c gcc/cp/pt.c
index 91a46745447..94706bc5ad1 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -25553,7 +25553,11 @@ value_dependent_expression_p (tree expression)
if (DECL_HAS_VALUE_EXPR_P (expression))
{
tree value_expr = DECL_VALUE_EXPR (expression);
- if (value_dependent_expression_p (value_expr))
+ if (value_dependent_expression_p (value_expr)
+ /* __PRETTY_FUNCTION__ inside a template function is dependent
+ on the name of the function. */
+ || (DECL_PRETTY_FUNCTION_P (expression)
+ && value_expr == error_mark_node))
Hmm, when would value_expr not be error_mark_node for
__PRETTY_FUNCTION__ in a template?
Jason