aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index cea8a51..54180a2 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1045,6 +1045,12 @@ add_method (tree type, tree method, tree using_decl)
overloaded if any of them is a static member
function declaration.
+ [over.load] Member function declarations with the same name and
+ the same parameter-type-list as well as member function template
+ declarations with the same name, the same parameter-type-list, and
+ the same template parameter lists cannot be overloaded if any of
+ them, but not all, have a ref-qualifier.
+
[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
@@ -1060,11 +1066,13 @@ add_method (tree type, tree method, tree using_decl)
coming from the using class in overload resolution. */
if (! DECL_STATIC_FUNCTION_P (fn)
&& ! DECL_STATIC_FUNCTION_P (method)
- && TREE_TYPE (TREE_VALUE (parms1)) != error_mark_node
- && TREE_TYPE (TREE_VALUE (parms2)) != error_mark_node
- && (cp_type_quals (TREE_TYPE (TREE_VALUE (parms1)))
- != cp_type_quals (TREE_TYPE (TREE_VALUE (parms2)))))
- continue;
+ /* Either both or neither need to be ref-qualified for
+ differing quals to allow overloading. */
+ && (FUNCTION_REF_QUALIFIED (fn_type)
+ == FUNCTION_REF_QUALIFIED (method_type))
+ && (type_memfn_quals (fn_type) != type_memfn_quals (method_type)
+ || type_memfn_rqual (fn_type) != type_memfn_rqual (method_type)))
+ continue;
/* For templates, the return type and template parameters
must be identical. */
@@ -2063,6 +2071,8 @@ same_signature_p (const_tree fndecl, const_tree base_fndecl)
base_types = TYPE_ARG_TYPES (TREE_TYPE (base_fndecl));
if ((cp_type_quals (TREE_TYPE (TREE_VALUE (base_types)))
== cp_type_quals (TREE_TYPE (TREE_VALUE (types))))
+ && (type_memfn_rqual (TREE_TYPE (fndecl))
+ == type_memfn_rqual (TREE_TYPE (base_fndecl)))
&& compparms (TREE_CHAIN (base_types), TREE_CHAIN (types)))
return 1;
}