From 01c39e4050b00a6483b1e196b1308beed14d6e4a Mon Sep 17 00:00:00 2001 From: dodji Date: Fri, 6 May 2011 08:34:10 +0000 Subject: [PATCH] Fix PR c++/48838 gcc/cp PR c++/48838 * cp-tree.h (non_static_member_function_p): Declare new function. * tree.c (non_static_member_function_p): Define it. * semantics.c (finish_call_expr): Use it. gcc/testsuite PR c++/48838 * g++.dg/template/member9.C: New test case. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@173472 138bc75d-0d04-0410-961f-82ee72b054a4 index 176a4b8..9fbca57 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -5409,6 +5409,7 @@ extern tree get_fns (tree); extern tree get_first_fn (tree); extern tree ovl_cons (tree, tree); extern tree build_overload (tree, tree); +extern bool non_static_member_function_p (tree); extern const char *cxx_printable_name (tree, int); extern const char *cxx_printable_name_translate (tree, int); extern tree build_exception_variant (tree, tree); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b5c0b80..f43649e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2041,8 +2041,7 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, is not included in *ARGS even though it is considered to be part of the list of arguments. Note that this is related to CWG issues 515 and 1005. */ - || (((TREE_CODE (TREE_TYPE (fn)) == METHOD_TYPE) - || BASELINK_P (fn)) + || (non_static_member_function_p (fn) && current_class_ref && type_dependent_expression_p (current_class_ref))) { diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 15ee741..f04fd23 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1465,6 +1465,34 @@ build_overload (tree decl, tree chain) return ovl_cons (decl, chain); } +/* Return TRUE if FN is a non-static member function, FALSE otherwise. + This function looks into BASELINK and OVERLOAD nodes. */ + +bool +non_static_member_function_p (tree fn) +{ + if (fn == NULL_TREE) + return false; + + if (BASELINK_P (fn)) + { + tree type = TREE_TYPE (fn); + + if (type && TREE_CODE (type) == METHOD_TYPE) + return true; + else if (type && TREE_CODE (type) == FUNCTION_TYPE) + return false; + /* This is an overload. Lets look into its current value. */ + fn = get_fns (BASELINK_FUNCTIONS (fn)); + } + + if (TREE_CODE (fn) == OVERLOAD) + fn = OVL_CURRENT (fn); + + return (DECL_P (fn) + && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)); +} + #define PRINT_RING_SIZE 4 new file mode 100644 index 0000000..f15272d --- /dev/null +++ b/gcc/testsuite/g++.dg/template/member9.C @@ -0,0 +1,21 @@ +// Origin PR c++/48838 +// { dg-do compile } + +class DUChainItemSystem +{ +public: + + template + void registerTypeClass(); + + static DUChainItemSystem& self(); +}; + +template +struct DUChainItemRegistrator +{ + DUChainItemRegistrator() + { + DUChainItemSystem::self().registerTypeClass(); + } +}; -- 1.7.0.4