aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1997-11-19 18:42:13 +0000
committerJason Merrill <jason@gcc.gnu.org>1997-11-19 13:42:13 -0500
commitbd2a82a625b2c8280f59db055ea87d3e89fa3e85 (patch)
treea206551334e97bd16b6ba21d96713be07d69a0ad
parent8d31729fce13f203ed45c83aef334aa90bff93ec (diff)
downloadgcc-bd2a82a625b2c8280f59db055ea87d3e89fa3e85.zip
gcc-bd2a82a625b2c8280f59db055ea87d3e89fa3e85.tar.gz
gcc-bd2a82a625b2c8280f59db055ea87d3e89fa3e85.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c41
2 files changed, 41 insertions, 5 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9fb7f04..efdf9a7 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+Wed Nov 19 10:39:27 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * 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 <haible@ilog.fr>
* pt.c (do_poplevel): Don't prohibit jumps into this contour.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 486897f..e015816 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);
}
}