mirror of git://gcc.gnu.org/git/gcc.git
re PR c++/55223 ([C++11] Default lambda expression of a templated class member)
PR c++/55223 gcc/cp/ * pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Fix handling of default argument scope. * mangle.c (write_name): Likewise. libiberty/ * cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_DEFAULT_ARG. (d_print_comp): Likewise. From-SVN: r196065
This commit is contained in:
parent
ff9b4073cc
commit
622aac0b88
|
@ -785,7 +785,8 @@ Driver Undocumented
|
||||||
; argument.
|
; argument.
|
||||||
; First selectable in G++ 4.7.
|
; First selectable in G++ 4.7.
|
||||||
;
|
;
|
||||||
; 7: The version of the ABI that treats nullptr_t as a builtin type.
|
; 7: The version of the ABI that treats nullptr_t as a builtin type and
|
||||||
|
; corrects the mangling of lambdas in default argument scope.
|
||||||
; First selectable in G++ 4.8.
|
; First selectable in G++ 4.8.
|
||||||
; Additional positive integers will be assigned as new versions of
|
; Additional positive integers will be assigned as new versions of
|
||||||
; the ABI become the default version of the ABI.
|
; the ABI become the default version of the ABI.
|
||||||
|
|
|
@ -1,5 +1,10 @@
|
||||||
2013-02-14 Jason Merrill <jason@redhat.com>
|
2013-02-14 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
PR c++/55223
|
||||||
|
* pt.c (tsubst_copy_and_build) [LAMBDA_EXPR]: Fix handling of
|
||||||
|
default argument scope.
|
||||||
|
* mangle.c (write_name): Likewise.
|
||||||
|
|
||||||
PR c++/55232
|
PR c++/55232
|
||||||
* error.c (find_typenames_r): Don't walk into a pack expansion.
|
* error.c (find_typenames_r): Don't walk into a pack expansion.
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,10 @@ write_name (tree decl, const int ignore_local_scope)
|
||||||
if (context == NULL
|
if (context == NULL
|
||||||
|| context == global_namespace
|
|| context == global_namespace
|
||||||
|| DECL_NAMESPACE_STD_P (context)
|
|| DECL_NAMESPACE_STD_P (context)
|
||||||
|| (ignore_local_scope && TREE_CODE (context) == FUNCTION_DECL))
|
|| (ignore_local_scope
|
||||||
|
&& (TREE_CODE (context) == FUNCTION_DECL
|
||||||
|
|| (abi_version_at_least (7)
|
||||||
|
&& TREE_CODE (context) == PARM_DECL))))
|
||||||
{
|
{
|
||||||
tree template_info;
|
tree template_info;
|
||||||
/* Is this a template instance? */
|
/* Is this a template instance? */
|
||||||
|
|
16
gcc/cp/pt.c
16
gcc/cp/pt.c
|
@ -14444,8 +14444,20 @@ tsubst_copy_and_build (tree t,
|
||||||
than build a new one. */
|
than build a new one. */
|
||||||
tree scope = LAMBDA_EXPR_EXTRA_SCOPE (t);
|
tree scope = LAMBDA_EXPR_EXTRA_SCOPE (t);
|
||||||
if (scope && TREE_CODE (scope) == FUNCTION_DECL)
|
if (scope && TREE_CODE (scope) == FUNCTION_DECL)
|
||||||
scope = tsubst (LAMBDA_EXPR_EXTRA_SCOPE (t), args,
|
scope = tsubst (scope, args, complain, in_decl);
|
||||||
complain, in_decl);
|
else if (scope && TREE_CODE (scope) == PARM_DECL)
|
||||||
|
{
|
||||||
|
/* Look up the parameter we want directly, as tsubst_copy
|
||||||
|
doesn't do what we need. */
|
||||||
|
tree fn = tsubst (DECL_CONTEXT (scope), args, complain, in_decl);
|
||||||
|
tree parm = FUNCTION_FIRST_USER_PARM (fn);
|
||||||
|
while (DECL_PARM_INDEX (parm) != DECL_PARM_INDEX (scope))
|
||||||
|
parm = DECL_CHAIN (parm);
|
||||||
|
scope = parm;
|
||||||
|
/* FIXME Work around the parm not having DECL_CONTEXT set. */
|
||||||
|
if (DECL_CONTEXT (scope) == NULL_TREE)
|
||||||
|
DECL_CONTEXT (scope) = fn;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
scope = RECUR (scope);
|
scope = RECUR (scope);
|
||||||
LAMBDA_EXPR_EXTRA_SCOPE (r) = scope;
|
LAMBDA_EXPR_EXTRA_SCOPE (r) = scope;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// PR c++/55223
|
||||||
|
// { dg-options "-std=c++11 -fabi-version=0" }
|
||||||
|
// { dg-final { scan-assembler "_ZN8functionC1IZN1CIiE4testES_Ed_UliE_EET_" } }
|
||||||
|
|
||||||
|
struct function
|
||||||
|
{
|
||||||
|
template <class U> function(U u) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename T> struct C
|
||||||
|
{
|
||||||
|
static T test(function f = [](int i){return i;}) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
C<int>::test();
|
||||||
|
}
|
|
@ -1,3 +1,8 @@
|
||||||
|
2013-02-14 Jason Merrill <jason@redhat.com>
|
||||||
|
|
||||||
|
* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_DEFAULT_ARG.
|
||||||
|
(d_print_comp): Likewise.
|
||||||
|
|
||||||
2013-02-09 Jakub Jelinek <jakub@redhat.com>
|
2013-02-09 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
PR other/56245
|
PR other/56245
|
||||||
|
|
|
@ -707,6 +707,14 @@ d_dump (struct demangle_component *dc, int indent)
|
||||||
case DEMANGLE_COMPONENT_TLS_WRAPPER:
|
case DEMANGLE_COMPONENT_TLS_WRAPPER:
|
||||||
printf ("tls wrapper function\n");
|
printf ("tls wrapper function\n");
|
||||||
break;
|
break;
|
||||||
|
case DEMANGLE_COMPONENT_DEFAULT_ARG:
|
||||||
|
printf ("default argument %d\n", dc->u.s_unary_num.num);
|
||||||
|
d_dump (dc->u.s_unary_num.sub, indent+2);
|
||||||
|
return;
|
||||||
|
case DEMANGLE_COMPONENT_LAMBDA:
|
||||||
|
printf ("lambda %d\n", dc->u.s_unary_num.num);
|
||||||
|
d_dump (dc->u.s_unary_num.sub, indent+2);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d_dump (d_left (dc), indent + 2);
|
d_dump (d_left (dc), indent + 2);
|
||||||
|
@ -3168,6 +3176,7 @@ d_expr_primary (struct d_info *di)
|
||||||
|
|
||||||
/* <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>]
|
/* <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>]
|
||||||
::= Z <(function) encoding> E s [<discriminator>]
|
::= Z <(function) encoding> E s [<discriminator>]
|
||||||
|
::= Z <(function) encoding> E d [<parameter> number>] _ <entity name>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct demangle_component *
|
static struct demangle_component *
|
||||||
|
@ -3869,7 +3878,17 @@ d_print_comp (struct d_print_info *dpi, int options,
|
||||||
d_append_string (dpi, "::");
|
d_append_string (dpi, "::");
|
||||||
else
|
else
|
||||||
d_append_char (dpi, '.');
|
d_append_char (dpi, '.');
|
||||||
d_print_comp (dpi, options, d_right (dc));
|
{
|
||||||
|
struct demangle_component *local_name = d_right (dc);
|
||||||
|
if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG)
|
||||||
|
{
|
||||||
|
d_append_string (dpi, "{default arg#");
|
||||||
|
d_append_num (dpi, local_name->u.s_unary_num.num + 1);
|
||||||
|
d_append_string (dpi, "}::");
|
||||||
|
local_name = local_name->u.s_unary_num.sub;
|
||||||
|
}
|
||||||
|
d_print_comp (dpi, options, local_name);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case DEMANGLE_COMPONENT_TYPED_NAME:
|
case DEMANGLE_COMPONENT_TYPED_NAME:
|
||||||
|
|
|
@ -3951,6 +3951,9 @@ S::f(int, int)::{default arg#2}::{lambda()#2}::operator()() const
|
||||||
_ZNK1SIiE1xMUlvE1_clEv
|
_ZNK1SIiE1xMUlvE1_clEv
|
||||||
S<int>::x::{lambda()#3}::operator()() const
|
S<int>::x::{lambda()#3}::operator()() const
|
||||||
--format=gnu-v3
|
--format=gnu-v3
|
||||||
|
_ZN8functionC1IZN1CIiE4testES_Ed_UliE_EET_
|
||||||
|
function::function<C<int>::test(function)::{default arg#1}::{lambda(int)#1}>(C<int>::test(function)::{default arg#1}::{lambda(int)#1})
|
||||||
|
--format=gnu-v3
|
||||||
_Z1fN1SUt_E
|
_Z1fN1SUt_E
|
||||||
f(S::{unnamed type#1})
|
f(S::{unnamed type#1})
|
||||||
--format=gnu-v3
|
--format=gnu-v3
|
||||||
|
|
Loading…
Reference in New Issue