init.c (build_member_call): Handle template-id expressions correctly.
authorMark Mitchell <mark@codesourcery.com>
Fri, 19 Mar 1999 12:13:39 +0000 (12:13 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Fri, 19 Mar 1999 12:13:39 +0000 (12:13 +0000)
* init.c (build_member_call): Handle template-id expressions
correctly.
* typeck.c (build_x_function_call): Likewise.

From-SVN: r25859

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/typeck.c
gcc/testsuite/g++.old-deja/g++.pt/crash31.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/memtemp82.C
gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C [new file with mode: 0644]

index 18766012742d78aa8cc585f0f6ef2bc65ab5f015..384e3e9141e0d11b03a6b11ea2fd6ef85a953145 100644 (file)
@@ -1,3 +1,9 @@
+1999-03-19  Mark Mitchell  <mark@codesourcery.com>
+
+       * init.c (build_member_call): Handle template-id expressions
+       correctly.
+       * typeck.c (build_x_function_call): Likewise.
+
 1999-03-19  Chip Salzenberg  <chip@perlsupport.com>
 
        * friend.c (make_friend_class): Avoid core dump when
index 98f26f59325dca21b83fa870b922b5f97f6da2e6..e4696616835b7dcfa3bef4b8184c6aa090915e43 100644 (file)
@@ -1381,7 +1381,11 @@ build_member_call (type, name, parmlist)
   if (TREE_CODE (name) != TEMPLATE_ID_EXPR)
     method_name = name;
   else
-    method_name = TREE_OPERAND (name, 0);
+    {
+      method_name = TREE_OPERAND (name, 0);
+      if (is_overloaded_fn (method_name))
+       method_name = DECL_NAME (OVL_CURRENT (method_name));
+    }
 
   if (TREE_CODE (method_name) == BIT_NOT_EXPR)
     {
index 0732bc800fe1e06f5faa9b7033e1eed89a6595d9..cfd931927ea9fa0e0081d71f08366633ec763176 100644 (file)
@@ -2585,6 +2585,15 @@ build_x_function_call (function, params, decl)
                                TYPE_BINFO (type), LOOKUP_NORMAL);
     }
     
+  if ((TREE_CODE (function) == FUNCTION_DECL
+       && DECL_STATIC_FUNCTION_P (function))
+      || (TREE_CODE (function) == TEMPLATE_DECL
+         && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
+      return build_member_call(DECL_CONTEXT (function), 
+                              template_id 
+                              ? template_id : DECL_NAME (function), 
+                              params);
+
   is_method = ((TREE_CODE (function) == TREE_LIST
                && current_class_type != NULL_TREE
                && (IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (function))
@@ -2593,13 +2602,6 @@ build_x_function_call (function, params, decl)
               || TREE_CODE (type) == METHOD_TYPE
               || TYPE_PTRMEMFUNC_P (type));
 
-  if ((TREE_CODE (function) == FUNCTION_DECL
-       && DECL_STATIC_FUNCTION_P (function))
-      || (TREE_CODE (function) == TEMPLATE_DECL
-         && DECL_STATIC_FUNCTION_P (DECL_RESULT (function))))
-    return build_member_call
-      (DECL_CONTEXT (function), DECL_NAME (function), params);
-
   /* A friend template.  Make it look like a toplevel declaration.  */
   if (! is_method && TREE_CODE (function) == TEMPLATE_DECL)
     function = scratch_ovl_cons (function, NULL_TREE);
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/crash31.C b/gcc/testsuite/g++.old-deja/g++.pt/crash31.C
new file mode 100644 (file)
index 0000000..3475896
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// Origin: Corey Kosak
+
+struct cow_t {
+  template<bool Q>
+  static void tfunc(cow_t *cowp) {}
+
+  void moo() {
+    cow_t *cowp;
+    cow_t::tfunc<true>(cowp);
+  }
+};
+
+
+int main()
+{
+  cow_t *cowp;
+  cow_t::tfunc<true>(cowp);
+}
index 9abd390f8b695f1786bfcf7ed544cc909ebcc5fb..d4bb37aa410933b9c0be36294ebda8fd7d3c84a8 100644 (file)
@@ -1,5 +1,5 @@
 // Build don't link:
-// excess errors test - XFAIL *-*-*
+// excess errors test
 
 struct foo {
        template<typename T> T bar() { return staticbar<T>( this ); }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C b/gcc/testsuite/g++.old-deja/g++.pt/memtemp83.C
new file mode 100644 (file)
index 0000000..69ab948
--- /dev/null
@@ -0,0 +1,19 @@
+// Build don't link:
+// Origin: Corey Kosak <kosak@cs.cmu.edu>
+
+struct cow_t {
+  template<bool Q>
+  static void tfunc(cow_t *cowp) {}
+
+  void moo() {
+    cow_t *cowp;
+    tfunc<true>(cowp);
+  }
+};
+
+
+int main()
+{
+  cow_t *cowp;
+  cow_t::tfunc<true>(cowp);
+}