PR c++/2294
authorgiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2003 15:23:31 +0000 (15:23 +0000)
committergiovannibajo <giovannibajo@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 7 Dec 2003 15:23:31 +0000 (15:23 +0000)
* name-lookup.c (push_overloaded_decl): Always construct an
OVERLOAD unless the declaration is a built-in.
(set_namespace_binding): While binding OVERLOADs with only one
declaration, we still need to call supplement_binding.
* init.c (build_new_1): Deal with an OVERLOAD set when
looking up for _Jv_AllocObject.
* except.c (build_throw): Likewise for _Jv_Throw.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@74394 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/except.c
gcc/cp/init.c
gcc/cp/name-lookup.c

index f2ec0e7..8105bfc 100644 (file)
@@ -1,3 +1,14 @@
+2003-12-07  Giovanni Bajo  <giovannibajo@gcc.gnu.org>\r
+\r
+       PR c++/2294\r
+       * name-lookup.c (push_overloaded_decl): Always construct an \r
+       OVERLOAD unless the declaration is a built-in.\r
+       (set_namespace_binding): While binding OVERLOADs with only one\r
+       declaration, we still need to call supplement_binding.\r
+       * init.c (build_new_1): Deal with an OVERLOAD set when\r
+       looking up for _Jv_AllocObject.\r
+       * except.c (build_throw): Likewise for _Jv_Throw.\r
+
 2003-12-06  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/13323
index 1dc149a..b684efb 100644 (file)
@@ -645,7 +645,12 @@ build_throw (tree exp)
          tmp = build_function_type (ptr_type_node, tmp);
          fn = push_throw_library_fn (fn, tmp);
        }
-
+      else if (really_overloaded_fn (fn))
+       {\r
+         error ("`%D' should never be overloaded", fn);
+         return error_mark_node;\r
+       }
+      fn = OVL_CURRENT (fn);
       exp = build_function_call (fn, tree_cons (NULL_TREE, exp, NULL_TREE));
     }
   else if (exp)
index 332c518..19642d6 100644 (file)
@@ -2005,11 +2005,18 @@ build_new_1 (tree exp)
       tree class_size = size_in_bytes (true_type);
       static const char alloc_name[] = "_Jv_AllocObject";
       use_java_new = 1;
-      alloc_decl = IDENTIFIER_GLOBAL_VALUE (get_identifier (alloc_name));
-      if (alloc_decl == NULL_TREE)
-       fatal_error ("call to Java constructor with `%s' undefined",
-                    alloc_name);
-
+      if (!get_global_value_if_present (get_identifier (alloc_name), 
+                                       &alloc_decl))
+       {\r
+         error ("call to Java constructor with `%s' undefined", alloc_name);
+         return error_mark_node;
+       }
+      else if (really_overloaded_fn (alloc_decl))
+       {\r
+         error ("`%D' should never be overloaded", alloc_decl);
+         return error_mark_node;
+       }
+      alloc_decl = OVL_CURRENT (alloc_decl);
       class_addr = build1 (ADDR_EXPR, jclass_node, class_decl);
       alloc_call = (build_function_call
                    (alloc_decl,
index a31aeeb..203cb1b 100644 (file)
@@ -2002,7 +2002,11 @@ push_overloaded_decl (tree decl, int flags)
        }
     }
 
-  if (old || TREE_CODE (decl) == TEMPLATE_DECL)
+  /* FIXME: We should build OVERLOADs for all function declarations here.
+     But right now, there are too many places where the code creates an
+     artificial declaration and expects the name to be bound exactly
+     to a FUNCTION_DECL.  */
+  if (!DECL_ARTIFICIAL (decl))
     {
       if (old && TREE_CODE (old) != OVERLOAD)
        new_binding = ovl_cons (decl, ovl_cons (old, NULL_TREE));
@@ -2012,7 +2016,6 @@ push_overloaded_decl (tree decl, int flags)
        OVL_USED (new_binding) = 1;
     }
   else
-    /* NAME is not ambiguous.  */
     new_binding = decl;
 
   if (doing_global)
@@ -2870,7 +2873,11 @@ set_namespace_binding (tree name, tree scope, tree val)
   if (scope == NULL_TREE)
     scope = global_namespace;
   b = binding_for_name (NAMESPACE_LEVEL (scope), name);
-  if (!b->value || TREE_CODE (val) == OVERLOAD || val == error_mark_node)
+  if (!b->value
+      /* If OVL_CHAIN is NULL, it's the first FUNCTION_DECL for this name,
+       and we still need to call supplement_binding.  */
+      || (TREE_CODE (val) == OVERLOAD && OVL_CHAIN (val))
+      || val == error_mark_node)
     b->value = val;
   else
     supplement_binding (b, val);