aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2001-12-18 10:18:20 -0500
committerJason Merrill <jason@gcc.gnu.org>2001-12-18 10:18:20 -0500
commit00e4119c09c83a7e3e7eb9694b17e080acb17811 (patch)
treec0ee817603a2faad5389bdd26f4f18f291dc5b3d
parent27aeb83f88b0350b7875cc79ddcef7edbee0df43 (diff)
downloadgcc-00e4119c09c83a7e3e7eb9694b17e080acb17811.zip
gcc-00e4119c09c83a7e3e7eb9694b17e080acb17811.tar.gz
gcc-00e4119c09c83a7e3e7eb9694b17e080acb17811.tar.bz2
class.c (add_method): Do compare 'this' quals when trying to match a used function.
* class.c (add_method): Do compare 'this' quals when trying to match a used function. Don't defer to another used function. From-SVN: r48157
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/class.c24
2 files changed, 25 insertions, 4 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index ff053dd..aea8e22 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2001-12-18 Jason Merrill <jason@redhat.com>
+
+ * class.c (add_method): Do compare 'this' quals when trying to match a
+ used function. Don't defer to another used function.
+
2001-12-18 Nathan Sidwell <nathan@codesourcery.com>
* pt.c (instantiate_clone): Remove, fold into ...
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 5201df7..c335c0b 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -972,22 +972,38 @@ add_method (type, method, error_p)
/* [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. */
+ 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). */
if ((DECL_STATIC_FUNCTION_P (fn)
!= DECL_STATIC_FUNCTION_P (method))
|| using)
{
tree parms1 = TYPE_ARG_TYPES (TREE_TYPE (fn));
tree parms2 = TYPE_ARG_TYPES (TREE_TYPE (method));
-
+ int same = 1;
+
+ /* 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 (using
+ && ! 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 (compparms (parms1, parms2))
+ if (same && compparms (parms1, parms2))
{
- if (using)
+ if (using && DECL_CONTEXT (fn) == type)
/* Defer to the local function. */
return;
else