semantics.c (finish_object_call_expr): Move test for the function called being a...
authorMark Mitchell <mark@markmitchell.com>
Thu, 16 Jul 1998 11:46:44 +0000 (11:46 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 16 Jul 1998 11:46:44 +0000 (11:46 +0000)
1998-07-16  Mark Mitchell  <mark@markmitchell.com>
* semantics.c (finish_object_call_expr): Move test for the
function called being a TYPE_DECL to ...
* call.c (build_new_method_call): Here.

From-SVN: r21213

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/semantics.c
gcc/testsuite/g++.old-deja/g++.pt/call1.C [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.pt/call2.C [new file with mode: 0644]

index 37a85a73d27c64d3e10b557db33f665bf1987e01..08b57eb98fbb96453ee1c2318b0ed1ec26880f05 100644 (file)
@@ -1,3 +1,9 @@
+1998-07-16  Mark Mitchell  <mark@markmitchell.com>
+
+       * semantics.c (finish_object_call_expr): Move test for the
+       function called being a TYPE_DECL to ...
+       * call.c (build_new_method_call): Here.
+
 1998-07-15  Jason Merrill  <jason@yorick.cygnus.com>
 
        * decl2.c (arg_assoc_class): Also look at template arguments, if any.
index 3e11a741fa5ccdf5329dd2c75d00bfe56cf54a97..7a8719153cb547806830129b0aa78f29ecb2e776 100644 (file)
@@ -3552,6 +3552,12 @@ build_new_method_call (instance, name, args, basetype_path, flags)
       template_only = 1;
     }
 
+  if (TREE_CODE (name) == TYPE_DECL)
+    {
+      cp_error ("calling type `%T' like a method", name);
+      return error_mark_node;
+    }
+    
   /* If there is an extra argument for controlling virtual bases,
      remove it for error reporting.  */
   if (flags & LOOKUP_HAS_IN_CHARGE)
index fe4709aee9553e06a5f62c2e422d43947bdc59b7..cae0b6734661ac9c0625de88f40a089a7d92934d 100644 (file)
@@ -922,12 +922,6 @@ finish_object_call_expr (fn, object, args)
   tree real_fn = build_component_ref (object, fn, NULL_TREE, 1);
   return finish_call_expr (real_fn, args);
 #else
-  if (TREE_CODE (fn) == TYPE_DECL)
-    {
-      cp_error ("calling type `%T' like a method", fn);
-      return error_mark_node;
-    }
-
   return build_method_call (object, fn, args, NULL_TREE, LOOKUP_NORMAL);
 #endif
 }
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/call1.C b/gcc/testsuite/g++.old-deja/g++.pt/call1.C
new file mode 100644 (file)
index 0000000..257d547
--- /dev/null
@@ -0,0 +1,13 @@
+// Build don't link:
+
+struct IsCompressed { };
+struct Field {
+  bool IsCompressed() const { return true; }
+};
+
+template<class C>
+inline bool
+for_each(const Field& p, IsCompressed, C)
+{
+  return p.IsCompressed();
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.pt/call2.C b/gcc/testsuite/g++.old-deja/g++.pt/call2.C
new file mode 100644 (file)
index 0000000..51b2469
--- /dev/null
@@ -0,0 +1,14 @@
+// Build don't link:
+
+struct IsCompressed { };
+struct Field {
+};
+
+template<class C>
+inline bool
+for_each(const Field& p, IsCompressed, C)
+{
+  return p.IsCompressed(); // ERROR - calling type like a method
+}
+
+template bool for_each<int>(const Field& p, IsCompressed, int); // ERROR - instantiated from here