aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-03-23 23:08:59 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-03-23 18:08:59 -0500
commitb3709d9b81438a2577bcba6271e45c53553b584e (patch)
tree40624676d7892a98410a9386d3308df81752e208 /gcc
parentbc289659328c9dc90c6870fae99ff83fc4d2d99b (diff)
downloadgcc-b3709d9b81438a2577bcba6271e45c53553b584e.zip
gcc-b3709d9b81438a2577bcba6271e45c53553b584e.tar.gz
gcc-b3709d9b81438a2577bcba6271e45c53553b584e.tar.bz2
decl.c (make_typename_type): Revert.
* decl.c (make_typename_type): Revert. (make_implicit_typename): Remove. (lookup_name_real): Don't call it. Call lookup_field if we see a TYPE_DECL from a template base. * search.c (lookup_field): Do implicit typename stuff. From-SVN: r18790
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/decl.c72
-rw-r--r--gcc/cp/search.c45
3 files changed, 35 insertions, 90 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b3fe9fc..291ceab 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,11 @@
+Mon Mar 23 12:24:37 1998 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (make_typename_type): Revert.
+ (make_implicit_typename): Remove.
+ (lookup_name_real): Don't call it. Call lookup_field if we see a
+ TYPE_DECL from a template base.
+ * search.c (lookup_field): Do implicit typename stuff.
+
Sun Mar 22 00:50:42 1998 Nick Clifton <nickc@cygnus.com>
Geoff Noer <noer@cygnus.com>
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 434d84c..7f2df3f 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4555,14 +4555,6 @@ make_typename_type (context, name)
return error_mark_node;
}
- /* If this is really from a base that uses template parms,
- push the TYPENAME_TYPE down. */
- if (processing_template_decl
- && context == current_class_type
- && DECL_CONTEXT (t) != context
- && uses_template_parms (DECL_CONTEXT (t)))
- return make_implicit_typename (context, t);
-
return TREE_TYPE (t);
}
}
@@ -4584,49 +4576,6 @@ make_typename_type (context, name)
return t;
}
-/* Given a TYPE_DECL T looked up in CONTEXT, return a TYPENAME_TYPE
- where the scope is the first class along the inheritance chain to T
- that is not current_class_type.
-
- Called from lookup_name_real to implement the implicit typename
- extension. */
-
-static tree
-make_implicit_typename (context, t)
- tree context, t;
-{
- tree retval;
-
- if (context == current_class_type)
- {
- tree binfos = TYPE_BINFO_BASETYPES (context);
- int n_baselinks = TREE_VEC_LENGTH (binfos);
- int i;
-
- /* We can't use DECL_CONTEXT (t) to help us here, because it refers
- to the uninstantiated template type that t comes from, which is
- probably not a base of ours. This happens because we don't
- actually do partial instantiation of types in
- instantiate_class_template. */
-
- for (i = 0; i < n_baselinks; ++i)
- {
- tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
- if (lookup_field (basetype, DECL_NAME (t), 0, 1))
- {
- context = basetype;
- break;
- }
- }
- }
-
- retval = make_typename_type (context, DECL_NAME (t));
-
- if (TREE_CODE (retval) == TYPENAME_TYPE)
- 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
@@ -4716,17 +4665,6 @@ lookup_name_real (name, prefer_type, nonclass)
else
val = NULL_TREE;
- /* Add implicit 'typename' to scoped types from other classes. */
- if (got_scope && processing_template_decl
- && got_scope != current_class_type
- && uses_template_parms (got_scope)
- && val && TREE_CODE (val) == TYPE_DECL
- && ! DECL_ARTIFICIAL (val))
- {
- tree t = make_implicit_typename (got_scope, val);
- val = TYPE_MAIN_DECL (t);
- }
-
if (got_scope)
goto done;
else if (got_object && val)
@@ -4756,16 +4694,14 @@ lookup_name_real (name, prefer_type, nonclass)
if (classval == NULL_TREE)
classval = lookup_nested_field (name, ! yylex);
- /* Add implicit 'typename' to types from base classes. */
+ /* Add implicit 'typename' to types from template bases. lookup_field
+ will do this for us. */
if (processing_template_decl
&& classval && TREE_CODE (classval) == TYPE_DECL
&& DECL_CONTEXT (classval) != current_class_type
- && uses_template_parms (DECL_CONTEXT (classval))
+ && uses_template_parms (current_class_type)
&& ! DECL_ARTIFICIAL (classval))
- {
- tree t = make_implicit_typename (current_class_type, classval);
- classval = TYPE_MAIN_DECL (t);
- }
+ classval = lookup_field (current_class_type, name, 0, 1);
}
if (locval && classval)
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index a12ebf4..fe0a3a4 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -1304,28 +1304,8 @@ lookup_field (xbasetype, name, protect, want_type)
}
}
- if (entry)
- {
- if (errstr)
- {
- /* This depends on behavior of lookup_field_1! */
- tree error_string = my_build_string (errstr);
- TREE_TYPE (entry) = error_string;
- }
- else
- {
- /* Let entry know there is no problem with this access. */
- TREE_TYPE (entry) = NULL_TREE;
- }
- TREE_VALUE (entry) = rval;
- }
-
- if (errstr && protect)
- {
- cp_error (errstr, name, type);
- return error_mark_node;
- }
- return rval;
+ rval_binfo = basetype_path;
+ goto out;
}
basetype_chain = build_expr_list (NULL_TREE, basetype_path);
@@ -1522,6 +1502,7 @@ lookup_field (xbasetype, name, protect, want_type)
: "member `%D' is from protected base class";
}
+ out:
if (entry)
{
if (errstr)
@@ -1550,6 +1531,26 @@ lookup_field (xbasetype, name, protect, want_type)
cp_error (errstr, name, type);
rval = error_mark_node;
}
+
+ /* Do implicit typename stuff. */
+ if (rval && TREE_CODE (rval) == TYPE_DECL
+ && ! DECL_ARTIFICIAL (rval)
+ && processing_template_decl
+ && BINFO_TYPE (rval_binfo) != current_class_type
+ && uses_template_parms (type))
+ {
+ binfo = rval_binfo;
+ for (; ; binfo = BINFO_INHERITANCE_CHAIN (binfo))
+ if (BINFO_INHERITANCE_CHAIN (binfo) == NULL_TREE
+ || (BINFO_TYPE (BINFO_INHERITANCE_CHAIN (binfo))
+ == current_class_type))
+ break;
+
+ entry = make_typename_type (BINFO_TYPE (binfo), name);
+ TREE_TYPE (entry) = TREE_TYPE (rval);
+ rval = TYPE_MAIN_DECL (entry);
+ }
+
return rval;
}