Hi,
On 05/28/2014 05:14 PM, Jason Merrill wrote:
On 05/28/2014 06:15 AM, Paolo Carlini wrote:
+ bool do_inject = (!current_class_ref
+ && TREE_CODE (t) == METHOD_TYPE
+ && TREE_CODE (TREE_TYPE (t)) == DECLTYPE_TYPE);
Let's do this for any METHOD_TYPE; the decltype could be nested as a
template argument. And current_class_ref might be for the wrong class.
Ok.
+ /* DR 1207: 'this' is in scope in the trailing return type. */
+ tree this_type = (current_class_type
+ ? current_class_type
+ : TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))));
And here let's use class_of_this_parm unconditionally.
But unconditionally doesn't work, without doing something more. For
example for the first test, as reported: when current_class_type is set
and equal to "struct X<int>", class_of_this_parm is "struct X<
<template-parameter-1-1> >". I'm trying to paste below the trees:
(gdb) p debug_tree(class_of_this_parm(t))
<record_type 0x7ffff6819a80 X type_0 type_5 type_6 VOID
size <integer_cst 0x7ffff66d58a0 type <integer_type 0x7ffff66d7150
bitsizetype> constant 0>
unit size <integer_cst 0x7ffff66d5858 type <integer_type
0x7ffff66d70a8 sizetype> constant 0>
align 8 symtab 0 alias set -1 canonical type 0x7ffff6819a80
fields <type_decl 0x7ffff6813b80 X
type <record_type 0x7ffff6819b28 X type_0 type_5 type_6 VOID
size <integer_cst 0x7ffff66d58a0 0> unit size <integer_cst 0x7ffff66d5858 0>
align 8 symtab 0 alias set -1 canonical type 0x7ffff6819a80
fields <type_decl 0x7ffff6813b80 X> context <translation_unit_decl
0x7ffff66e0170 D.1>
full-name "struct X< <template-parameter-1-1> >"
n_parents=0 use_template=0 interface-unknown
chain <type_decl 0x7ffff6813a10 X>>
used nonlocal decl_4 VOID file 57543_1.C line 5 col 1
align 1 context <record_type 0x7ffff6819a80 X> result
<record_type 0x7ffff6819a80 X>
> context <translation_unit_decl 0x7ffff66e0170 D.1>
full-name "struct X< <template-parameter-1-1> >"
n_parents=0 use_template=0 interface-unknown
pointer_to_this <pointer_type 0x7ffff6819d20> chain <type_decl
0x7ffff6813a10 X>>
$3 = void
(gdb) p current_class_type
$4 = (tree) 0x7ffff682a2a0
(gdb) p debug_tree(current_class_type)
<record_type 0x7ffff682a2a0 X type_5 type_6 VOID
align 8 symtab 0 alias set -1 canonical type 0x7ffff682a2a0
fields <type_decl 0x7ffff682c0b8 X
type <record_type 0x7ffff682a348 X used type_5 type_6 VOID
align 8 symtab 0 alias set -1 canonical type 0x7ffff682a2a0
context <translation_unit_decl 0x7ffff66e0170 D.1>
full-name "struct X<int>"
n_parents=0 use_template=1 interface-unknown
chain <type_decl 0x7ffff6813f18 X>>
used external nonlocal suppress-debug decl_4 VOID file
57543_1.C line 5 col 1
align 8 context <record_type 0x7ffff682a2a0 X> result
<record_type 0x7ffff682a2a0 X>
> context <translation_unit_decl 0x7ffff66e0170 D.1>
full-name "struct X<int>"
n_parents=0 use_template=1 interface-unknown
pointer_to_this <pointer_type 0x7ffff682a3f0> chain <type_decl
0x7ffff6813f18 X>>