Commit f0ab6bf2 by Mark Mitchell Committed by Mark Mitchell

re PR c++/7224 (g++ 3.x does not tecognize unused ambiguous inline member functions)

	PR c++/7224
	* class.c (add_method): Simplify.

	PR c++/7224
	* g++.dg/overload/error1.C: New test.

From-SVN: r55409
parent c5386123
2002-07-11 Mark Mitchell <mark@codesourcery.com>
PR c++/7224
* class.c (add_method): Simplify.
2002-07-11 Jason Merrill <jason@redhat.com> 2002-07-11 Jason Merrill <jason@redhat.com>
PR c++/7279 PR c++/7279
......
...@@ -966,69 +966,57 @@ add_method (type, method, error_p) ...@@ -966,69 +966,57 @@ add_method (type, method, error_p)
fns = OVL_NEXT (fns)) fns = OVL_NEXT (fns))
{ {
tree fn = OVL_CURRENT (fns); tree fn = OVL_CURRENT (fns);
tree parms1;
tree parms2;
bool same = 1;
if (TREE_CODE (fn) != TREE_CODE (method)) if (TREE_CODE (fn) != TREE_CODE (method))
continue; continue;
if (TREE_CODE (method) != TEMPLATE_DECL) /* [over.load] Member function declarations with the
same name and the same parameter types cannot be
overloaded if any of them is a static member
function declaration.
[namespace.udecl] When a using-declaration brings names
from a base class into a derived class scope, member
functions in the derived class override and/or hide member
functions with the same name and parameter types in a base
class (rather than conflicting). */
parms1 = TYPE_ARG_TYPES (TREE_TYPE (fn));
parms2 = TYPE_ARG_TYPES (TREE_TYPE (method));
/* Compare the quals on the 'this' parm. Don't compare
the whole types, as used functions are treated as
coming from the using class in overload resolution. */
if (! DECL_STATIC_FUNCTION_P (fn)
&& ! DECL_STATIC_FUNCTION_P (method)
&& (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1)))
!= TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2)))))
same = 0;
if (! DECL_STATIC_FUNCTION_P (fn))
parms1 = TREE_CHAIN (parms1);
if (! DECL_STATIC_FUNCTION_P (method))
parms2 = TREE_CHAIN (parms2);
if (same && compparms (parms1, parms2))
{ {
/* [over.load] Member function declarations with the if (using && DECL_CONTEXT (fn) == type)
same name and the same parameter types cannot be /* Defer to the local function. */
overloaded if any of them is a static member return;
function declaration. else
[namespace.udecl] When a using-declaration brings names
from a base class into a derived class scope, member
functions in the derived class override and/or hide member
functions with the same name and parameter types in a base
class (rather than conflicting). */
if ((DECL_STATIC_FUNCTION_P (fn)
!= DECL_STATIC_FUNCTION_P (method))
|| using)
{ {
tree parms1 = TYPE_ARG_TYPES (TREE_TYPE (fn)); cp_error_at ("`%#D' and `%#D' cannot be overloaded",
tree parms2 = TYPE_ARG_TYPES (TREE_TYPE (method)); method, fn, method);
int same = 1;
/* We don't call duplicate_decls here to merge
/* Compare the quals on the 'this' parm. Don't compare the declarations because that will confuse
the whole types, as used functions are treated as things if the methods have inline
coming from the using class in overload resolution. */ definitions. In particular, we will crash
if (using while processing the definitions. */
&& ! DECL_STATIC_FUNCTION_P (fn) return;
&& ! DECL_STATIC_FUNCTION_P (method)
&& (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1)))
!= TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2)))))
same = 0;
if (! DECL_STATIC_FUNCTION_P (fn))
parms1 = TREE_CHAIN (parms1);
if (! DECL_STATIC_FUNCTION_P (method))
parms2 = TREE_CHAIN (parms2);
if (same && compparms (parms1, parms2))
{
if (using && DECL_CONTEXT (fn) == type)
/* Defer to the local function. */
return;
else
error ("`%#D' and `%#D' cannot be overloaded",
fn, method);
}
} }
} }
if (!decls_match (fn, method))
continue;
/* There has already been a declaration of this method
or member template. */
cp_error_at ("`%D' has already been declared in `%T'",
method, type);
/* We don't call duplicate_decls here to merge the
declarations because that will confuse things if the
methods have inline definitions. In particular, we
will crash while processing the definitions. */
return;
} }
} }
......
2002-07-11 Mark Mitchell <mark@codesourcery.com>
PR c++/7224
* g++.dg/overload/error1.C: New test.
2002-07-11 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> 2002-07-11 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
* gcc.misc-tests/linkage.exp: Handle mips-sgi-irix6*o32 * gcc.misc-tests/linkage.exp: Handle mips-sgi-irix6*o32
......
// { dg-do compile }
struct S
{
void f () {}
int f () { return 0; } // { dg-error "" "" }
};
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