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
This commit is contained in:
Jason Merrill 1998-07-12 01:30:11 +00:00 committed by Jason Merrill
parent 555f90c5ef
commit 2b9dc906d0
7 changed files with 64 additions and 32 deletions

View File

@ -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.

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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)
{

View File

@ -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));
}