C++ PATCH to typename_sub2
Jason Merrill
jason@redhat.com
Thu Dec 21 09:37:00 GMT 2000
We need to return the TYPE_DECL from typename_sub2, so that if we're not
dealing with templates we don't forget what name we used.
// Bug: typename_sub2 returned the type, so we tried to look up "A" in B.
// Build don't link:
struct A { struct A1 { }; };
struct B {
typedef A Q;
};
struct C: public B::Q::A1 { };
2000-12-20 Jason Merrill <jason@redhat.com>
* parse.y (typename_sub2): Return the TYPE_DECL, not the type.
*** parse.y.~1~ Thu Dec 21 17:08:17 2000
--- parse.y Thu Dec 21 17:08:18 2000
*************** typename_sub1:
*** 3056,3061 ****
--- 3056,3063 ----
{
if (TREE_CODE ($1) == IDENTIFIER_NODE)
cp_error ("`%T' is not a class or namespace", $1);
+ else if (TREE_CODE ($1) == TYPE_DECL)
+ $$ = TREE_TYPE ($1);
}
| typename_sub1 typename_sub2
{
*************** typename_sub1:
*** 3078,3101 ****
= make_typename_type ($1, $3, /*complain=*/1); }
;
typename_sub2:
TYPENAME SCOPE
{
! if (TREE_CODE ($1) != IDENTIFIER_NODE)
! $1 = lastiddecl;
/* Retrieve the type for the identifier, which might involve
some computation. */
! got_scope = $$ = complete_type (IDENTIFIER_TYPE_VALUE ($1));
if ($$ == error_mark_node)
cp_error ("`%T' is not a class or namespace", $1);
}
| SELFNAME SCOPE
{
! if (TREE_CODE ($1) != IDENTIFIER_NODE)
$$ = lastiddecl;
! got_scope = $$ = complete_type (TREE_TYPE ($$));
}
| template_type SCOPE
{ got_scope = $$ = complete_type (TREE_TYPE ($$)); }
--- 3080,3105 ----
= make_typename_type ($1, $3, /*complain=*/1); }
;
+ /* This needs to return a TYPE_DECL for simple names so that we don't
+ forget what name was used. */
typename_sub2:
TYPENAME SCOPE
{
! if (TREE_CODE ($1) != TYPE_DECL)
! $$ = lastiddecl;
/* Retrieve the type for the identifier, which might involve
some computation. */
! got_scope = complete_type (TREE_TYPE ($$));
if ($$ == error_mark_node)
cp_error ("`%T' is not a class or namespace", $1);
}
| SELFNAME SCOPE
{
! if (TREE_CODE ($1) != TYPE_DECL)
$$ = lastiddecl;
! got_scope = complete_type (TREE_TYPE ($$));
}
| template_type SCOPE
{ got_scope = $$ = complete_type (TREE_TYPE ($$)); }
More information about the Gcc-patches
mailing list