From: Jason Merrill Date: Wed, 19 Nov 1997 18:42:13 +0000 (+0000) Subject: decl.c (make_implicit_typename): New fn. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bd2a82a625b2c8280f59db055ea87d3e89fa3e85;p=gcc.git decl.c (make_implicit_typename): New fn. * decl.c (make_implicit_typename): New fn. (lookup_name_real): Use it. Use current_class_type as the context. From-SVN: r16581 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 9fb7f04fab6..efdf9a769e6 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +Wed Nov 19 10:39:27 1997 Jason Merrill + + * decl.c (make_implicit_typename): New fn. + (lookup_name_real): Use it. Use current_class_type as the context. + Mon Nov 17 23:42:03 1997 Bruno Haible * pt.c (do_poplevel): Don't prohibit jumps into this contour. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 486897f0a95..e0158162e9d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4372,6 +4372,40 @@ make_typename_type (context, name) return t; } +/* Given a TYPE_DECL T looked up in CONTEXT, return a TYPENAME_TYPE + where the scope is either CONTEXT or the first base of CONTEXT along the + inheritance chain to T that depends on template parameters. + + Called from lookup_name_real to implement the implicit typename + extension. */ + +static tree +make_implicit_typename (context, t) + tree context, t; +{ + tree retval; + + if (uses_template_parms (DECL_CONTEXT (t)) + && DECL_CONTEXT (t) != context) + { + tree binfo = get_binfo (DECL_CONTEXT (t), context, 0); + for (;;) + { + tree next = BINFO_INHERITANCE_CHAIN (binfo); + if (! uses_template_parms (BINFO_TYPE (next)) + || BINFO_TYPE (next) == context) + break; + binfo = next; + } + retval = make_typename_type (BINFO_TYPE (binfo), DECL_NAME (t)); + } + else + retval = make_typename_type (context, DECL_NAME (t)); + + TREE_TYPE (retval) = TREE_TYPE (t); + return retval; +} + /* Look up NAME in the current binding level and its superiors in the namespace of variables, functions and typedefs. Return a ..._DECL node of some kind representing its definition if there is only one @@ -4464,8 +4498,7 @@ lookup_name_real (name, prefer_type, nonclass) && val && TREE_CODE (val) == TYPE_DECL && ! DECL_ARTIFICIAL (val)) { - tree t = make_typename_type (got_scope, DECL_NAME (val)); - TREE_TYPE (t) = TREE_TYPE (val); + tree t = make_implicit_typename (got_scope, val); val = TYPE_MAIN_DECL (t); } @@ -4505,9 +4538,7 @@ lookup_name_real (name, prefer_type, nonclass) && uses_template_parms (DECL_CONTEXT (classval)) && ! DECL_ARTIFICIAL (classval)) { - tree t = make_typename_type (DECL_CONTEXT (classval), - DECL_NAME (classval)); - TREE_TYPE (t) = TREE_TYPE (classval); + tree t = make_implicit_typename (current_class_type, classval); classval = TYPE_MAIN_DECL (t); } }