Commit cbb40945 by Nathan Sidwell Committed by Nathan Sidwell

cp-tree.h (IDENTIFIER_VIRTUAL_P): Document.

cp:
	* cp-tree.h (IDENTIFIER_VIRTUAL_P): Document.
	(get_matching_virtual): Remove.
	(look_for_overrides): Declare new function.
	* decl.c (grokfndecl): Don't set IDENTIFIER_VIRTUAL_P or
	DECL_VINDEX here.
	* class.c (check_for_override): Move base class iteration code
	to look_for_overrides.
	* search.c (next_baselink): Remove.
	(get_virtuals_named_this): Remove.
	(get_virtual_destructor): Remove.
	(tree_has_any_destructors_p): Remove.
	(struct gvnt_info): Remove.
	(check_final_overrider): Remove `virtual' from error messages.
	(get_matching_virtuals): Remove. Move functionality to ...
	(look_for_overrides): ... here, and ...
	(look_for_overrides_r): ... here. Set DECL_VIRTUAL_P, if found
	to be overriding.
testsuite:
	* g++.old-deja/g++.h/spec6.C: Remove some of the XFAILS.
	* g++.old-deja/g++.other/virtual10.C: New test.

From-SVN: r38040
parent 61402b80
2000-12-05 Nathan Sidwell <nathan@codesourcery.com> 2000-12-05 Nathan Sidwell <nathan@codesourcery.com>
* cp-tree.h (IDENTIFIER_VIRTUAL_P): Document.
(get_matching_virtual): Remove.
(look_for_overrides): Declare new function.
* decl.c (grokfndecl): Don't set IDENTIFIER_VIRTUAL_P or
DECL_VINDEX here.
* class.c (check_for_override): Move base class iteration code
to look_for_overrides.
* search.c (next_baselink): Remove.
(get_virtuals_named_this): Remove.
(get_virtual_destructor): Remove.
(tree_has_any_destructors_p): Remove.
(struct gvnt_info): Remove.
(check_final_overrider): Remove `virtual' from error messages.
(get_matching_virtuals): Remove. Move functionality to ...
(look_for_overrides): ... here, and ...
(look_for_overrides_r): ... here. Set DECL_VIRTUAL_P, if found
to be overriding.
2000-12-05 Nathan Sidwell <nathan@codesourcery.com>
* typeck.c (get_delta_difference): If via a virtual base, * typeck.c (get_delta_difference): If via a virtual base,
return zero. return zero.
* cvt.c (cp_convert_to_pointer): If via a virtual base, do no * cvt.c (cp_convert_to_pointer): If via a virtual base, do no
......
...@@ -2910,56 +2910,24 @@ static void ...@@ -2910,56 +2910,24 @@ static void
check_for_override (decl, ctype) check_for_override (decl, ctype)
tree decl, ctype; tree decl, ctype;
{ {
tree binfos = BINFO_BASETYPES (TYPE_BINFO (ctype)); if (TREE_CODE (decl) == TEMPLATE_DECL)
int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0; /* In [temp.mem] we have:
int virtualp = DECL_VIRTUAL_P (decl);
int found_overriden_fn = 0;
for (i = 0; i < n_baselinks; i++) A specialization of a member function template does not
{ override a virtual function from a base class. */
tree base_binfo = TREE_VEC_ELT (binfos, i); return;
if (TYPE_POLYMORPHIC_P (BINFO_TYPE (base_binfo))) if ((DECL_DESTRUCTOR_P (decl)
{ || IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)))
tree tmp = get_matching_virtual && look_for_overrides (ctype, decl)
(base_binfo, decl, DECL_DESTRUCTOR_P (decl)); && !DECL_STATIC_FUNCTION_P (decl))
{
if (tmp && !found_overriden_fn) /* Set DECL_VINDEX to a value that is neither an
{ INTEGER_CST nor the error_mark_node so that
/* If this function overrides some virtual in some base add_virtual_function will realize this is an
class, then the function itself is also necessarily overriding function. */
virtual, even if the user didn't explicitly say so. */ DECL_VINDEX (decl) = decl;
DECL_VIRTUAL_P (decl) = 1; }
if (DECL_VIRTUAL_P (decl))
/* The TMP we really want is the one from the deepest
baseclass on this path, taking care not to
duplicate if we have already found it (via another
path to its virtual baseclass. */
if (TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
{
cp_error_at ("`static %#D' cannot be declared", decl);
cp_error_at (" since `virtual %#D' declared in base class",
tmp);
break;
}
virtualp = 1;
/* Set DECL_VINDEX to a value that is neither an
INTEGER_CST nor the error_mark_node so that
add_virtual_function will realize this is an
overridden function. */
DECL_VINDEX (decl)
= tree_cons (tmp, NULL_TREE, DECL_VINDEX (decl));
/* We now know that DECL overrides something,
which is all that is important. But, we must
continue to iterate through all the base-classes
in order to allow get_matching_virtual to check for
various illegal overrides. */
found_overriden_fn = 1;
}
}
}
if (virtualp)
{ {
if (DECL_VINDEX (decl) == NULL_TREE) if (DECL_VINDEX (decl) == NULL_TREE)
DECL_VINDEX (decl) = error_mark_node; DECL_VINDEX (decl) = error_mark_node;
......
...@@ -514,7 +514,8 @@ struct tree_srcloc ...@@ -514,7 +514,8 @@ struct tree_srcloc
#define SET_IDENTIFIER_ERROR_LOCUS(NODE,VALUE) \ #define SET_IDENTIFIER_ERROR_LOCUS(NODE,VALUE) \
SET_LANG_ID(NODE, VALUE, error_locus) SET_LANG_ID(NODE, VALUE, error_locus)
/* Nonzero if this identifier is used as a virtual function name somewhere
(optimizes searches). */
#define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1(NODE) #define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1(NODE)
/* Nonzero if this identifier is the prefix for a mangled C++ operator /* Nonzero if this identifier is the prefix for a mangled C++ operator
...@@ -4250,7 +4251,7 @@ extern tree lookup_field PARAMS ((tree, tree, int, int)); ...@@ -4250,7 +4251,7 @@ extern tree lookup_field PARAMS ((tree, tree, int, int));
extern int lookup_fnfields_1 PARAMS ((tree, tree)); extern int lookup_fnfields_1 PARAMS ((tree, tree));
extern tree lookup_fnfields PARAMS ((tree, tree, int)); extern tree lookup_fnfields PARAMS ((tree, tree, int));
extern tree lookup_member PARAMS ((tree, tree, int, int)); extern tree lookup_member PARAMS ((tree, tree, int, int));
extern tree get_matching_virtual PARAMS ((tree, tree, int)); extern int look_for_overrides PARAMS ((tree, tree));
extern void get_pure_virtuals PARAMS ((tree)); extern void get_pure_virtuals PARAMS ((tree));
extern tree init_vbase_pointers PARAMS ((tree, tree)); extern tree init_vbase_pointers PARAMS ((tree, tree));
extern void get_vbase_types PARAMS ((tree)); extern void get_vbase_types PARAMS ((tree));
......
...@@ -9038,12 +9038,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals, ...@@ -9038,12 +9038,7 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
return decl; return decl;
if (virtualp) if (virtualp)
{ DECL_VIRTUAL_P (decl) = 1;
DECL_VIRTUAL_P (decl) = 1;
if (DECL_VINDEX (decl) == NULL_TREE)
DECL_VINDEX (decl) = error_mark_node;
IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
}
return decl; return decl;
} }
......
2000-12-05 Nathan Sidwell <nathan@codesourcery.com> 2000-12-05 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.h/spec6.C: Remove some of the XFAILS.
* g++.old-deja/g++.other/virtual10.C: New test.
2000-12-05 Nathan Sidwell <nathan@codesourcery.com>
* g++.old-deja/g++.mike/pmf5.C: Remove test. * g++.old-deja/g++.mike/pmf5.C: Remove test.
2000-12-05 Richard Henderson <rth@redhat.com> 2000-12-05 Richard Henderson <rth@redhat.com>
......
...@@ -92,7 +92,7 @@ struct A ...@@ -92,7 +92,7 @@ struct A
virtual void wobble(int) throw(E *); // ERROR - overriding virtual void wobble(int) throw(E *); // ERROR - overriding
virtual void wabble(int) throw(E *); virtual void wabble(int) throw(E *);
virtual void wubble(int) throw(E *, H *); virtual void wubble(int) throw(E *, H *);
virtual ~A() throw(); // ERROR - overriding XFAIL virtual ~A() throw(); // ERROR - overriding
}; };
struct B : A struct B : A
...@@ -133,9 +133,7 @@ struct C : A, A1 ...@@ -133,9 +133,7 @@ struct C : A, A1
struct D : A, A1 struct D : A, A1
{ {
// The xfail here is because we don't have the check in the right place to virtual ~D() throw(int); // ERROR - looser throw - A::~A()
// catch dtor failings.
virtual ~D() throw(int); // ERROR - looser throw - A::~A() - XFAIL
}; };
// [except.spec] 5, types shall not be defined in exception specifiers // [except.spec] 5, types shall not be defined in exception specifiers
......
// Build don't link:
// Copyright (C) 2000 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 14 Nov 2000 <nathan@codesourcery.com>
// We failed to spot a static member which overrode a virtual
struct A
{
virtual int foo (char);
static int foo ();
virtual int foo (int); // ERROR - this function
static int foo (float);
virtual int foo (double);
};
struct B : A
{
static int foo (int); // ERROR - cannot override
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment