OSDN Git Service

(struct function): Make frame_offset be HOST_WIDE_INT.
[pf3gnuchains/gcc-fork.git] / gcc / cp / method.c
index aa607e6..c7e3a87 100644 (file)
@@ -39,10 +39,6 @@ Boston, MA 02111-1307, USA.  */
 #include "hard-reg-set.h"
 #include "flags.h"
 
-#ifndef SUPPORTS_ONE_ONLY
-#define SUPPORTS_ONE_ONLY 0
-#endif
-
 /* TREE_LIST of the current inline functions that need to be
    processed.  */
 struct pending_inline *pending_inlines;
@@ -66,10 +62,6 @@ static char *scratch_firstobj;
 # define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
 # define OB_LAST() (obstack_next_free (&scratch_obstack)[-1])
 
-#ifdef NO_AUTO_OVERLOAD
-int is_overloaded ();
-#endif
-
 void
 init_method ()
 {
@@ -153,6 +145,7 @@ do_inline_function_hair (type, friend_list)
 \f
 /* Report an argument type mismatch between the best declared function
    we could find and the current argument list that we have.  */
+
 void
 report_type_mismatch (cp, parmtypes, name_kind)
      struct candidate *cp;
@@ -261,6 +254,7 @@ static int nofold;
   } while (0)
 
 /* Code to concatenate an asciified integer to a string.  */
+
 static
 #ifdef __GNUC__
 __inline
@@ -355,7 +349,8 @@ build_overload_nested_name (decl)
     build_overload_identifier (decl);
 }
 
-/* Encoding for an INTEGER_CST value. */
+/* Encoding for an INTEGER_CST value.  */
+
 static void
 build_overload_int (value)
      tree value;
@@ -370,7 +365,7 @@ build_overload_int (value)
        OB_PUTC ('_');
       return;
     }
-  else if (current_template_parms
+  else if (processing_template_decl
           && TREE_CODE (value) != INTEGER_CST)
     /* We don't ever want this output, but it's inconvenient not to
        be able to build the string.  This should cause assembler
@@ -383,7 +378,7 @@ build_overload_int (value)
     }
 
   my_friendly_assert (TREE_CODE (value) == INTEGER_CST, 243);
-  if (TYPE_PRECISION (value) == 2 * HOST_BITS_PER_WIDE_INT)
+  if (TYPE_PRECISION (TREE_TYPE (value)) == 2 * HOST_BITS_PER_WIDE_INT)
     {
       if (tree_int_cst_lt (value, integer_zero_node))
        {
@@ -499,7 +494,7 @@ build_overload_value (type, value)
        {
          if (TREE_CODE (value) == CONSTRUCTOR)
            {
-             /* This is dangerous code, crack built up pointer to members. */
+             /* This is dangerous code, crack built up pointer to members.  */
              tree args = CONSTRUCTOR_ELTS (value);
              tree a1 = TREE_VALUE (args);
              tree a2 = TREE_VALUE (TREE_CHAIN (args));
@@ -671,7 +666,14 @@ build_overload_name (parmtypes, begin, end)
 
          if (TREE_USED (parmtype))
            {
+#if 0
+             /* We can turn this on at some point when we want
+                improved symbol mangling.  */
+             nrepeats++;
+#else
+             /* This is bug compatible with 2.7.x  */
              flush_repeats (parmtype);
+#endif
              goto next;
            }
 
@@ -876,7 +878,7 @@ build_overload_name (parmtypes, begin, end)
              {
                tree context = name;
 
-               /* If DECL_ASSEMBLER_NAME has been set properly, use it. */
+               /* If DECL_ASSEMBLER_NAME has been set properly, use it.  */
                if (DECL_ASSEMBLER_NAME (context) != DECL_NAME (context))
                  {
                    OB_PUTID (DECL_ASSEMBLER_NAME (context));
@@ -946,7 +948,7 @@ build_overload_name (parmtypes, begin, end)
       if (nrepeats)
        flush_repeats (typevec[maxtype-1]);
 
-      /* To get here, parms must end with `...'. */
+      /* To get here, parms must end with `...'.  */
       OB_PUTC ('e');
     }
 
@@ -974,6 +976,7 @@ build_static_name (basetype, name)
    FOR_METHOD is 1 if this overload is being performed
    for a method, rather than a function type.  It is 2 if
    this overload is being performed for a constructor.  */
+
 tree
 build_decl_overload (dname, parms, for_method)
      tree dname;
@@ -1058,6 +1061,7 @@ build_decl_overload (dname, parms, for_method)
 }
 
 /* Build an overload name for the type expression TYPE.  */
+
 tree
 build_typename_overload (type)
      tree type;
@@ -1100,55 +1104,6 @@ get_id_2 (name, name2)
   OB_FINISH ();
   return get_identifier (obstack_base (&scratch_obstack));
 }
-
-/* Top-level interface to explicit overload requests. Allow NAME
-   to be overloaded. Error if NAME is already declared for the current
-   scope. Warning if function is redundantly overloaded. */
-
-void
-declare_overloaded (name)
-     tree name;
-{
-#ifdef NO_AUTO_OVERLOAD
-  if (is_overloaded (name))
-    warning ("function `%s' already declared overloaded",
-            IDENTIFIER_POINTER (name));
-  else if (IDENTIFIER_GLOBAL_VALUE (name))
-    error ("overloading function `%s' that is already defined",
-          IDENTIFIER_POINTER (name));
-  else
-    {
-      TREE_OVERLOADED (name) = 1;
-      IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE);
-      TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node;
-    }
-#else
-  if (current_lang_name == lang_name_cplusplus)
-    {
-      if (0)
-       warning ("functions are implicitly overloaded in C++");
-    }
-  else if (current_lang_name == lang_name_c)
-    error ("overloading function `%s' cannot be done in C language context");
-  else
-    my_friendly_abort (76);
-#endif
-}
-
-#ifdef NO_AUTO_OVERLOAD
-/* Check to see if NAME is overloaded. For first approximation,
-   check to see if its TREE_OVERLOADED is set.  This is used on
-   IDENTIFIER nodes.  */
-int
-is_overloaded (name)
-     tree name;
-{
-  /* @@ */
-  return (TREE_OVERLOADED (name)
-         && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0)
-         && ! IDENTIFIER_LOCAL_VALUE (name));
-}
-#endif
 \f
 /* Given a tree_code CODE, and some arguments (at least one),
    attempt to use an overloaded operator on the arguments.
@@ -1187,6 +1142,9 @@ build_opfncall (code, flags, xarg1, xarg2, arg3)
   int try_second;
   int binary_is_unary;
 
+  if (flag_ansi_overloading)
+    return build_new_op (code, flags, xarg1, xarg2, arg3);
+
   if (xarg1 == error_mark_node)
     return error_mark_node;
 
@@ -1267,7 +1225,7 @@ build_opfncall (code, flags, xarg1, xarg2, arg3)
           
        if (TREE_CODE (TREE_TYPE (arg1)) == ARRAY_TYPE)
          {
-           /* Strip off the pointer and the array. */
+           /* Strip off the pointer and the array.  */
            arg1 = TREE_TYPE (TREE_TYPE (arg1));
 
            while (TREE_CODE (arg1) == ARRAY_TYPE)
@@ -1325,7 +1283,7 @@ build_opfncall (code, flags, xarg1, xarg2, arg3)
       /* Try to fail. First, fail if unary */
       if (! try_second)
        return rval;
-      /* Second, see if second argument is non-aggregate. */
+      /* Second, see if second argument is non-aggregate.  */
       type2 = TREE_TYPE (xarg2);
       if (TREE_CODE (type2) == OFFSET_TYPE)
        type2 = TREE_TYPE (type2);
@@ -1416,9 +1374,8 @@ build_opfncall (code, flags, xarg1, xarg2, arg3)
 
                  /* There's probably a LOT of code in the world that
                     relies upon this old behavior.  */
-                 if (! flag_traditional)
-                   pedwarn ("no `operator%s (int)' declared for postfix `%s', using prefix operator instead",
-                            op, op);
+                 pedwarn ("no `operator%s (int)' declared for postfix `%s', using prefix operator instead",
+                          op, op);
                  xarg2 = NULL_TREE;
                  binary_is_unary = 1;
                }
@@ -1644,7 +1601,7 @@ hack_identifier (value, name)
       return value;
     }
 
-  if (TREE_CODE (type) == REFERENCE_TYPE && ! current_template_parms)
+  if (TREE_CODE (type) == REFERENCE_TYPE && ! processing_template_decl)
     value = convert_from_reference (value);
   return value;
 }
@@ -1693,19 +1650,11 @@ make_thunk (function, delta)
       TREE_READONLY (thunk) = TYPE_READONLY (TREE_TYPE (vtable_entry_type));
       TREE_THIS_VOLATILE (thunk) = TYPE_VOLATILE (TREE_TYPE (vtable_entry_type));
       make_function_rtl (thunk);
+      comdat_linkage (thunk);
       TREE_SET_CODE (thunk, THUNK_DECL);
       DECL_INITIAL (thunk) = function;
       THUNK_DELTA (thunk) = delta;
       DECL_EXTERNAL (thunk) = 1;
-#ifdef DECL_ONE_ONLY
-      if (SUPPORTS_ONE_ONLY)
-       {
-         DECL_ONE_ONLY (thunk) = 1;
-         TREE_PUBLIC (thunk) = 1;
-       }
-      else
-#endif
-       TREE_PUBLIC (thunk) = 0;
       /* So that finish_file can write out any thunks that need to be: */
       pushdecl_top_level (thunk);
     }
@@ -1727,11 +1676,11 @@ emit_thunk (thunk_fndecl)
   int failure = 0;
   int save_ofp;
 
-  /* Used to remember which regs we need to emit a USE rtx for. */
+  /* Used to remember which regs we need to emit a USE rtx for.  */
   rtx need_use[FIRST_PSEUDO_REGISTER];
   int need_use_count = 0;
 
-  /* rtx for the 'this' parameter. */
+  /* rtx for the 'this' parameter.  */
   rtx this_rtx = 0, this_reg_rtx = 0, fixed_this_rtx;
 
   char *(*save_decl_printable_name) () = decl_printable_name;
@@ -1750,6 +1699,8 @@ emit_thunk (thunk_fndecl)
   if (current_function_decl)
     abort ();
   current_function_decl = thunk_fndecl;
+
+  TREE_SET_CODE (thunk_fndecl, FUNCTION_DECL);
 #ifdef ASM_OUTPUT_MI_THUNK
   temporary_allocation ();
   assemble_start_function (thunk_fndecl, fnname);
@@ -1773,7 +1724,7 @@ emit_thunk (thunk_fndecl)
 
   /* Now look through all the parameters, make sure that we
      don't clobber any registers used for parameters.
-     Also, pick up an rtx for the first "this" parameter. */
+     Also, pick up an rtx for the first "this" parameter.  */
   for (argp = TYPE_ARG_TYPES (TREE_TYPE (function));
        argp != NULL_TREE;
        argp = TREE_CHAIN (argp))
@@ -1937,6 +1888,7 @@ emit_thunk (thunk_fndecl)
   permanent_allocation (1);
   flag_omit_frame_pointer = save_ofp;
 #endif /* ASM_OUTPUT_MI_THUNK */
+  TREE_SET_CODE (thunk_fndecl, THUNK_DECL);
 
   decl_printable_name = save_decl_printable_name;
   current_function_decl = 0;
@@ -1946,6 +1898,7 @@ emit_thunk (thunk_fndecl)
 
 /* For the anonymous union in TYPE, return the member that is at least as
    large as the rest of the members, so we can copy it.  */
+
 static tree
 largest_union_member (type)
      tree type;
@@ -1962,6 +1915,7 @@ largest_union_member (type)
 }
 
 /* Generate code for default X(X&) constructor.  */
+
 void
 do_build_copy_constructor (fndecl)
      tree fndecl;
@@ -2162,11 +2116,13 @@ synthesize_method (fndecl)
   tree context = hack_decl_function_context (fndecl);
   tree base = DECL_CLASS_CONTEXT (fndecl);
 
-  if (nested)
+  if (! context)
+    push_to_top_level ();
+  else if (nested)
     push_cp_function_context (context);
 
   interface_unknown = 1;
-  start_function (NULL_TREE, fndecl, NULL_TREE, NULL_TREE, 1);
+  start_function (NULL_TREE, fndecl, NULL_TREE, 1);
   store_parm_decls ();
 
   if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR])
@@ -2192,11 +2148,18 @@ synthesize_method (fndecl)
       /* Turn off DECL_INLINE for the moment so function_cannot_inline_p
          will check our size.  */
       DECL_INLINE (fndecl) = 0;
-      if (function_cannot_inline_p (fndecl) == 0)
+
+      /* We say !at_eof because at the end of the file some of the rtl
+        for fndecl may have been allocated on the temporary obstack.
+        (The function_obstack is the temporary one if we're not in a
+        function). */
+      if ((! at_eof) && function_cannot_inline_p (fndecl) == 0)
        DECL_INLINE (fndecl) = 1;
     }
 
   extract_interface_info ();
-  if (nested)
+  if (! context)
+    pop_from_top_level ();
+  else if (nested)
     pop_cp_function_context (context);
 }