Commit 4bcd47e2 by Jason Merrill Committed by Jason Merrill

PR c++/89422 - ICE with -g and lambda in default arg in template.

Here, we were trying to instantiate the default argument before setting
DECL_FRIEND_CONTEXT, so that the instantiated lambda ended up being treated
as part of the S template, which confused dwarf2out.

	* pt.c (tsubst_function_decl): SET_DECL_FRIEND_CONTEXT sooner.

From-SVN: r269081
parent 5498361c
2019-02-21 Jason Merrill <jason@redhat.com> 2019-02-21 Jason Merrill <jason@redhat.com>
PR c++/89422 - ICE with -g and lambda in default arg in template.
* pt.c (tsubst_function_decl): SET_DECL_FRIEND_CONTEXT sooner.
2019-02-21 Jason Merrill <jason@redhat.com>
PR c++/88419 - C++17 ICE with class template arg deduction. PR c++/88419 - C++17 ICE with class template arg deduction.
* pt.c (make_template_placeholder): Set TYPE_CANONICAL after * pt.c (make_template_placeholder): Set TYPE_CANONICAL after
CLASS_PLACEHOLDER_TEMPLATE. CLASS_PLACEHOLDER_TEMPLATE.
......
...@@ -13088,6 +13088,11 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, ...@@ -13088,6 +13088,11 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
set_constraints (r, ci); set_constraints (r, ci);
} }
if (DECL_FRIEND_P (t) && DECL_FRIEND_CONTEXT (t))
SET_DECL_FRIEND_CONTEXT (r,
tsubst (DECL_FRIEND_CONTEXT (t),
args, complain, in_decl));
/* Set up the DECL_TEMPLATE_INFO for R. There's no need to do /* Set up the DECL_TEMPLATE_INFO for R. There's no need to do
this in the special friend case mentioned above where this in the special friend case mentioned above where
GEN_TMPL is NULL. */ GEN_TMPL is NULL. */
...@@ -13149,11 +13154,6 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, ...@@ -13149,11 +13154,6 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain,
&& !grok_op_properties (r, /*complain=*/true)) && !grok_op_properties (r, /*complain=*/true))
return error_mark_node; return error_mark_node;
if (DECL_FRIEND_P (t) && DECL_FRIEND_CONTEXT (t))
SET_DECL_FRIEND_CONTEXT (r,
tsubst (DECL_FRIEND_CONTEXT (t),
args, complain, in_decl));
/* Possibly limit visibility based on template args. */ /* Possibly limit visibility based on template args. */
DECL_VISIBILITY (r) = VISIBILITY_DEFAULT; DECL_VISIBILITY (r) = VISIBILITY_DEFAULT;
if (DECL_VISIBILITY_SPECIFIED (t)) if (DECL_VISIBILITY_SPECIFIED (t))
......
// PR c++/89422
// { dg-do compile { target c++11 } }
// { dg-additional-options -g }
template <int> struct S
{
friend void foo (int a = []{ return 0; }()) {}
int b;
};
S<0> t;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment