diff options
author | Jason Merrill <jason@redhat.com> | 2019-02-21 18:07:47 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2019-02-21 18:07:47 -0500 |
commit | 4bcd47e2e1975635ea18d61accf7dcbf64306aa7 (patch) | |
tree | d9de31bfc8c53aab2a8ee9e2a71c36c0d9799a23 /gcc | |
parent | 5498361c0f4822b2c48f19835963afa5a630175b (diff) | |
download | gcc-4bcd47e2e1975635ea18d61accf7dcbf64306aa7.zip gcc-4bcd47e2e1975635ea18d61accf7dcbf64306aa7.tar.gz gcc-4bcd47e2e1975635ea18d61accf7dcbf64306aa7.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/cp/pt.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg9.C | 10 |
3 files changed, 20 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 228100a..2f99f2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 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. * pt.c (make_template_placeholder): Set TYPE_CANONICAL after CLASS_PLACEHOLDER_TEMPLATE. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index bd0a3d1..76fb625 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13088,6 +13088,11 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, 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 this in the special friend case mentioned above where GEN_TMPL is NULL. */ @@ -13149,11 +13154,6 @@ tsubst_function_decl (tree t, tree args, tsubst_flags_t complain, && !grok_op_properties (r, /*complain=*/true)) 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. */ DECL_VISIBILITY (r) = VISIBILITY_DEFAULT; if (DECL_VISIBILITY_SPECIFIED (t)) diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg9.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg9.C new file mode 100644 index 0000000..f0436ad --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-defarg9.C @@ -0,0 +1,10 @@ +// 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; |