re PR c++/48838 (valid template code does not compile)
authorDodji Seketeli <dodji@redhat.com>
Fri, 6 May 2011 08:34:53 +0000 (08:34 +0000)
committerDodji Seketeli <dodji@gcc.gnu.org>
Fri, 6 May 2011 08:34:53 +0000 (10:34 +0200)
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.

From-SVN: r173473

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/member9.C [new file with mode: 0644]

index 9dbb57f1049d055177dd9c31bf23b9e77101b4d2..dfaaeaa54c1e262037201b8ee504d89b0100702a 100644 (file)
@@ -1,3 +1,10 @@
+2011-05-06  Dodji Seketeli  <dodji@redhat.com>
+
+       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.
+
 2011-05-05  Nathan Froyd  <froydnj@codesourcery.com>
 
        * decl.c (finish_case_label): Omit the loc argument to
index fcb715ce7ddb436106fbbde3e36fe17efc768ea5..9d13393502d202c5d6e1fa0dc2885212fa936f80 100644 (file)
@@ -5432,6 +5432,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);
index 8bf5a521dd4883c32eca4665883500a3c343c8a4..a2b24d3e31d751d8b04477a4ae326f31e53353d5 100644 (file)
@@ -2039,8 +2039,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)))
        {
index 32303930527753d70bd8e285d31db6368afed33c..d636548895701ba7bd8772fd3be40f2de8205102 100644 (file)
@@ -1480,6 +1480,22 @@ 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 (is_overloaded_fn (fn))
+    fn = get_first_fn (fn);
+
+  return (DECL_P (fn)
+         && DECL_NONSTATIC_MEMBER_FUNCTION_P (fn));
+}
+
 \f
 #define PRINT_RING_SIZE 4
 
index 0fe877fac3f34d8cb0e1b1d07b7bd3d2b4a368b9..3e89c93a1595e8c3663c0470c1df88d4b8a60aaa 100644 (file)
@@ -1,3 +1,8 @@
+2011-05-06  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/48838
+       * g++.dg/template/member9.C: New test case.
+
 2011-05-05  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gnat.dg/discr29.ad[sb]: New test.
diff --git a/gcc/testsuite/g++.dg/template/member9.C b/gcc/testsuite/g++.dg/template/member9.C
new file mode 100644 (file)
index 0000000..f15272d
--- /dev/null
@@ -0,0 +1,21 @@
+// Origin PR c++/48838
+// { dg-do compile }
+
+class DUChainItemSystem
+{
+public:
+
+    template<class T>
+    void registerTypeClass();
+
+    static DUChainItemSystem& self();
+};
+
+template<class T>
+struct DUChainItemRegistrator
+{
+    DUChainItemRegistrator()
+    {
+        DUChainItemSystem::self().registerTypeClass<T>();
+    }
+};