aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-07-12 01:30:11 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-07-11 21:30:11 -0400
commit2b9dc906d0445906387fa231ee5081bb4f3a7abc (patch)
treef19dba58a0e689a830924e88bdb5d136e6ba39d5
parent555f90c5ef78860b3ebcc4ff8e8201fa4bf4fb6f (diff)
downloadgcc-2b9dc906d0445906387fa231ee5081bb4f3a7abc.zip
gcc-2b9dc906d0445906387fa231ee5081bb4f3a7abc.tar.gz
gcc-2b9dc906d0445906387fa231ee5081bb4f3a7abc.tar.bz2
friend.c (do_friend): Pull the identifier out of declarator.
* friend.c (do_friend): Pull the identifier out of declarator. Use cp_error and friends. * decl2.c (qualified_lookup_using_namespace): Fix call to purpose_member. * decl.c (lookup_name_real): Don't call complete_type on a namespace. (grokvardecl): Use DECL_CLASS_SCOPE_P. (xref_basetypes): Fix call to GNU_xref_hier. * cvt.c (convert_pointer_to_real): Check for error_mark_node sooner. * class.c (warn_hidden): Fix for OVERLOAD. From grahams@rcp.co.uk: * cp-tree.h (DEFARG_NODE_CHECK): New macro. (DEFARG_LENGTH, DEFARG_POINTER): Use it. From-SVN: r21068
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/class.c24
-rw-r--r--gcc/cp/cp-tree.h5
-rw-r--r--gcc/cp/cvt.c6
-rw-r--r--gcc/cp/decl.c22
-rw-r--r--gcc/cp/decl2.c2
-rw-r--r--gcc/cp/friend.c22
7 files changed, 64 insertions, 32 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index dd77447..310376d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,18 @@
+1998-07-12 Jason Merrill <jason@yorick.cygnus.com>
+
+ * friend.c (do_friend): Pull the identifier out of declarator.
+ Use cp_error and friends.
+ * decl2.c (qualified_lookup_using_namespace): Fix call to
+ purpose_member.
+ * decl.c (lookup_name_real): Don't call complete_type on a namespace.
+ (grokvardecl): Use DECL_CLASS_SCOPE_P.
+ (xref_basetypes): Fix call to GNU_xref_hier.
+ * cvt.c (convert_pointer_to_real): Check for error_mark_node sooner.
+ * class.c (warn_hidden): Fix for OVERLOAD.
+ From grahams@rcp.co.uk:
+ * cp-tree.h (DEFARG_NODE_CHECK): New macro.
+ (DEFARG_LENGTH, DEFARG_POINTER): Use it.
+
Sun Jul 12 01:20:57 1998 Jeffrey A Law (law@cygnus.com)
* g++.1 (-traditional): Remove duplicated documentation.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index f9b99f0..4399592 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2929,12 +2929,14 @@ warn_hidden (t)
/* We go through each separately named virtual function. */
for (i = 2; i < n_methods; ++i)
{
- tree fndecl = TREE_VEC_ELT (method_vec, i);
+ tree fns = TREE_VEC_ELT (method_vec, i);
+ tree fndecl;
tree base_fndecls = NULL_TREE;
tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ fndecl = OVL_CURRENT (fns);
if (DECL_VINDEX (fndecl) == NULL_TREE)
continue;
@@ -2949,11 +2951,11 @@ warn_hidden (t)
base_fndecls);
}
- if (TREE_CHAIN (fndecl)
- && DECL_NAME (TREE_CHAIN (fndecl)) == DECL_NAME (fndecl))
- fndecl = TREE_CHAIN (fndecl);
- else
- fndecl = NULL_TREE;
+ fns = OVL_NEXT (fns);
+ if (fns)
+ fndecl = OVL_CURRENT (fns);
+ else
+ fndecl = NULL_TREE;
/* ...then mark up all the base functions with overriders, preferring
overriders to hiders. */
@@ -2962,9 +2964,9 @@ warn_hidden (t)
{
mark_overriders (fndecl, base_fndecls);
- if (TREE_CHAIN (fndecl)
- && DECL_NAME (TREE_CHAIN (fndecl)) == DECL_NAME (fndecl))
- fndecl = TREE_CHAIN (fndecl);
+ fns = OVL_NEXT (fns);
+ if (fns)
+ fndecl = OVL_CURRENT (fns);
else
fndecl = NULL_TREE;
}
@@ -4856,6 +4858,10 @@ push_nested_class (type, modify)
{
tree context;
+ /* FIXME should handle namespaces like classes. */
+ if (TREE_CODE (type) == NAMESPACE_DECL)
+ return;
+
if (type == NULL_TREE || type == error_mark_node || ! IS_AGGR_TYPE (type)
|| TREE_CODE (type) == TEMPLATE_TYPE_PARM
|| TREE_CODE (type) == TEMPLATE_TEMPLATE_PARM)
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 71ae911..735dc8a 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1655,8 +1655,9 @@ extern int flag_new_for_scope;
#define UPT_PARMS(NODE) TREE_VALUE(TYPE_VALUES(NODE))
/* An un-parsed default argument looks like an identifier. */
-#define DEFARG_LENGTH(NODE) IDENTIFIER_LENGTH(NODE)
-#define DEFARG_POINTER(NODE) IDENTIFIER_POINTER(NODE)
+#define DEFARG_NODE_CHECK(t) TREE_CHECK(t, DEFAULT_ARG)
+#define DEFARG_LENGTH(NODE) (DEFARG_NODE_CHECK(NODE)->identifier.length)
+#define DEFARG_POINTER(NODE) (DEFARG_NODE_CHECK(NODE)->identifier.pointer)
#define builtin_function(NAME, TYPE, CODE, LIBNAME) \
define_function (NAME, TYPE, CODE, (void (*) PROTO((tree)))pushdecl, LIBNAME)
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 5c4c0b0..18b7d8b 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -554,6 +554,9 @@ convert_pointer_to_real (binfo, expr)
tree ptr_type;
tree type, rval;
+ if (intype == error_mark_node)
+ return error_mark_node;
+
if (TREE_CODE (binfo) == TREE_VEC)
type = BINFO_TYPE (binfo);
else if (IS_AGGR_TYPE (binfo))
@@ -572,9 +575,6 @@ convert_pointer_to_real (binfo, expr)
if (ptr_type == TYPE_MAIN_VARIANT (intype))
return expr;
- if (intype == error_mark_node)
- return error_mark_node;
-
my_friendly_assert (!integer_zerop (expr), 191);
if (TREE_CODE (type) == RECORD_TYPE
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index d8522e0..40c60bd 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4784,7 +4784,8 @@ lookup_name_real (name, prefer_type, nonclass, namespaces_only)
if (TREE_CODE (type) == TYPENAME_TYPE && TREE_TYPE (type))
type = TREE_TYPE (type);
- type = complete_type (type);
+ if (TYPE_P (type))
+ type = complete_type (type);
if (TREE_CODE (type) == VOID_TYPE)
type = global_namespace;
@@ -7876,8 +7877,7 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
/* In class context, static means one per class,
public access, and static storage. */
- if (DECL_FIELD_CONTEXT (decl) != NULL_TREE
- && IS_AGGR_TYPE (DECL_FIELD_CONTEXT (decl)))
+ if (DECL_CLASS_SCOPE_P (decl))
{
TREE_PUBLIC (decl) = 1;
TREE_STATIC (decl) = 1;
@@ -11309,6 +11309,9 @@ xref_basetypes (code_type_node, name, ref, binfo)
SET_CLASSTYPE_MARKED (ref);
BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos = make_tree_vec (len);
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
for (i = 0; binfo; binfo = TREE_CHAIN (binfo))
{
/* The base of a derived struct is public by default. */
@@ -11329,10 +11332,6 @@ xref_basetypes (code_type_node, name, ref, binfo)
tree basetype = TREE_VALUE (binfo);
tree base_binfo;
- GNU_xref_hier (IDENTIFIER_POINTER (name),
- IDENTIFIER_POINTER (TREE_VALUE (binfo)),
- via_public, via_virtual, 0);
-
if (basetype && TREE_CODE (basetype) == TYPE_DECL)
basetype = TREE_TYPE (basetype);
if (!basetype
@@ -11345,11 +11344,16 @@ xref_basetypes (code_type_node, name, ref, binfo)
TREE_VALUE (binfo));
continue;
}
+
+ GNU_xref_hier (IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (TYPE_IDENTIFIER (basetype)),
+ via_public, via_virtual, 0);
+
#if 1
/* This code replaces similar code in layout_basetypes.
We put the complete_type first for implicit `typename'. */
- else if (TYPE_SIZE (complete_type (basetype)) == NULL_TREE
- && ! (current_template_parms && uses_template_parms (basetype)))
+ if (TYPE_SIZE (complete_type (basetype)) == NULL_TREE
+ && ! (current_template_parms && uses_template_parms (basetype)))
{
cp_error ("base class `%T' has incomplete type", basetype);
continue;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 8f84407..ccf00f5 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3995,7 +3995,7 @@ qualified_lookup_using_namespace (name, scope, result)
usings = TREE_CHAIN (usings))
/* If this was a real directive, and we have not seen it. */
if (!TREE_INDIRECT_USING (usings)
- && !purpose_member (seen, TREE_PURPOSE (usings)))
+ && !purpose_member (TREE_PURPOSE (usings), seen))
todo = temp_tree_cons (TREE_PURPOSE (usings), NULL_TREE, todo);
if (todo)
{
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index e36d306..6a7083c 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -322,6 +322,15 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
/* Every decl that gets here is a friend of something. */
DECL_FRIEND_P (decl) = 1;
+ if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
+ {
+ declarator = TREE_OPERAND (declarator, 0);
+ if (TREE_CODE (declarator) == LOOKUP_EXPR)
+ declarator = TREE_OPERAND (declarator, 0);
+ if (is_overloaded_fn (declarator))
+ declarator = DECL_NAME (get_first_fn (declarator));
+ }
+
if (TREE_CODE (decl) == FUNCTION_DECL)
is_friend_template = processing_template_decl >
template_class_depth (current_class_type);
@@ -371,9 +380,8 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
if (fields)
add_friends (current_class_type, declarator, ctype);
else
- error ("method `%s' is not a member of class `%s'",
- IDENTIFIER_POINTER (declarator),
- IDENTIFIER_POINTER (cname));
+ cp_error ("method `%D' is not a member of class `%T'",
+ declarator, ctype);
decl = void_type_node;
}
}
@@ -453,8 +461,7 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
tree decl = lookup_name_nonclass (declarator);
if (decl == NULL_TREE)
{
- warning ("implicitly declaring `%s' as struct",
- IDENTIFIER_POINTER (declarator));
+ cp_warning ("implicitly declaring `%T' as struct", declarator);
decl = xref_tag (record_type_node, declarator, NULL_TREE, 1);
decl = TYPE_MAIN_DECL (decl);
}
@@ -463,9 +470,8 @@ do_friend (ctype, declarator, decl, parmdecls, flags, quals, funcdef_flag)
but not if those functions are really class names. */
if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl)))
{
- warning ("`friend %s' archaic, use `friend class %s' instead",
- IDENTIFIER_POINTER (declarator),
- IDENTIFIER_POINTER (declarator));
+ cp_warning ("`friend %T' archaic, use `friend class %T' instead",
+ declarator, declarator);
decl = TREE_TYPE (TREE_PURPOSE (decl));
}