OSDN Git Service

* decl.c (finish_method): Give methods once-only linkage.
[pf3gnuchains/gcc-fork.git] / gcc / java / decl.c
index ad1b55e..ea7a9b4 100644 (file)
@@ -263,24 +263,14 @@ check_local_unnamed_variable (tree best, tree decl, tree type)
         initially held a pointer arg -- or vice versa -- we create a
         new VAR_DECL.  
 
-        ???: As long as verification is correct, this will be a
+        ???: As long as verification is correct, this will be a
         compatible type.  But maybe we should create a dummy variable
         and replace all references to it with the DECL and a
-        NOP_EXPR.
+        NOP_EXPR.  
       */
       || (TREE_CODE (decl_type) == POINTER_TYPE
          && TREE_CODE (decl) == PARM_DECL
-         && TREE_CODE (type) == POINTER_TYPE)
-
-      /* The new verifier requires a similar treatment in the
-        situation where the parameter has an integral type which
-        promotes to `int'.  */
-      || (flag_new_verifier
-         && TREE_CODE (decl) == PARM_DECL
-         && INTEGRAL_TYPE_P (decl_type)
-         && TYPE_PRECISION (decl_type) <= 32
-         && INTEGRAL_TYPE_P (type)
-         && TYPE_PRECISION (type) <= 32))
+         && TREE_CODE (type) == POINTER_TYPE))
     {
       if (best == NULL_TREE
          || (decl_type == type && TREE_TYPE (best) != type))
@@ -312,6 +302,16 @@ find_local_variable (int index, tree type, int pc ATTRIBUTE_UNUSED)
       tmp = DECL_LOCAL_SLOT_CHAIN (tmp);
     }
 
+  /* gcj has a function called promote_type(), which is used by both
+     the bytecode compiler and the source compiler.  Unfortunately,
+     the type systems for the Java VM and the Java language are not
+     the same: a boolean in the VM promotes to an int, not to a wide
+     boolean.  If our caller wants something to hold a boolean, that
+     had better be an int, because that slot might be re-used
+     later in integer context.  */
+  if (TREE_CODE (type) == BOOLEAN_TYPE)
+    type = integer_type_node;
+
   /* If we don't find a match, create one with the type passed in.
      The name of the variable is #n#m, which n is the variable index
      in the local variable area and m is a dummy identifier for
@@ -2036,6 +2036,13 @@ finish_method (tree fndecl)
                    build2 (TRY_FINALLY_EXPR, void_type_node, *tp, exit));
     }
 
+  /* Ensure non-abstract non-static non-private members are defined only once
+     when linking. This is an issue when using CNI to interface with C++ object
+     files.  */
+  if (! METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)
+      && ! METHOD_ABSTRACT (fndecl))
+    make_decl_one_only (fndecl);
+
   /* Prepend class initialization for static methods reachable from
      other classes.  */
   if (METHOD_STATIC (fndecl) && ! METHOD_PRIVATE (fndecl)