OSDN Git Service

Delete remaining references to sparc little-endian support.
[pf3gnuchains/gcc-fork.git] / gcc / c-aux-info.c
index ee9c516..694f9c1 100644 (file)
@@ -2,14 +2,14 @@
    on information stored in GCC's tree structure.  This code implements the
    -aux-info option.
    Copyright (C) 1989, 1991, 1994, 1995, 1997, 1998,
    on information stored in GCC's tree structure.  This code implements the
    -aux-info option.
    Copyright (C) 1989, 1991, 1994, 1995, 1997, 1998,
-   1999, 2000 Free Software Foundation, Inc.
+   1999, 2000, 2003, 2004, 2007, 2010 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@segfault.us.com).
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
    Contributed by Ron Guilmette (rfg@segfault.us.com).
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -18,13 +18,13 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 #include "config.h"
 #include "system.h"
 
 #include "config.h"
 #include "system.h"
-#include "toplev.h"
+#include "coretypes.h"
+#include "tm.h"
 #include "flags.h"
 #include "tree.h"
 #include "c-tree.h"
 #include "flags.h"
 #include "tree.h"
 #include "c-tree.h"
@@ -39,12 +39,11 @@ typedef enum formals_style_enum formals_style;
 
 static const char *data_type;
 
 
 static const char *data_type;
 
-static char *affix_data_type           PARAMS ((const char *));
-static const char *gen_formal_list_for_type PARAMS ((tree, formals_style));
-static int   deserves_ellipsis         PARAMS ((tree));
-static const char *gen_formal_list_for_func_def PARAMS ((tree, formals_style));
-static const char *gen_type            PARAMS ((const char *, tree, formals_style));
-static const char *gen_decl            PARAMS ((tree, int, formals_style));
+static char *affix_data_type (const char *) ATTRIBUTE_MALLOC;
+static const char *gen_formal_list_for_type (tree, formals_style);
+static const char *gen_formal_list_for_func_def (tree, formals_style);
+static const char *gen_type (const char *, tree, formals_style);
+static const char *gen_decl (tree, int, formals_style);
 \f
 /* Given a string representing an entire type or an entire declaration
    which only lacks the actual "data-type" specifier (at its left end),
 \f
 /* Given a string representing an entire type or an entire declaration
    which only lacks the actual "data-type" specifier (at its left end),
@@ -61,30 +60,27 @@ static const char *gen_decl         PARAMS ((tree, int, formals_style));
    that look as expected.  */
 
 static char *
    that look as expected.  */
 
 static char *
-affix_data_type (param)
-     const char *param;
+affix_data_type (const char *param)
 {
 {
-  char *type_or_decl = (char *) alloca (strlen (param) + 1);
+  char *const type_or_decl = ASTRDUP (param);
   char *p = type_or_decl;
   char *qualifiers_then_data_type;
   char saved;
 
   char *p = type_or_decl;
   char *qualifiers_then_data_type;
   char saved;
 
-  strcpy (type_or_decl, param);
-  
   /* Skip as many leading const's or volatile's as there are.  */
 
   for (;;)
     {
       if (!strncmp (p, "volatile ", 9))
   /* Skip as many leading const's or volatile's as there are.  */
 
   for (;;)
     {
       if (!strncmp (p, "volatile ", 9))
-        {
-          p += 9;
-          continue;
-        }
+       {
+         p += 9;
+         continue;
+       }
       if (!strncmp (p, "const ", 6))
       if (!strncmp (p, "const ", 6))
-        {
-          p += 6;
-          continue;
-        }
+       {
+         p += 6;
+         continue;
+       }
       break;
     }
 
       break;
     }
 
@@ -98,7 +94,8 @@ affix_data_type (param)
   *p = '\0';
   qualifiers_then_data_type = concat (type_or_decl, data_type, NULL);
   *p = saved;
   *p = '\0';
   qualifiers_then_data_type = concat (type_or_decl, data_type, NULL);
   *p = saved;
-  return concat (qualifiers_then_data_type, " ", p, NULL);
+  return reconcat (qualifiers_then_data_type,
+                  qualifiers_then_data_type, " ", p, NULL);
 }
 
 /* Given a tree node which represents some "function type", generate the
 }
 
 /* Given a tree node which represents some "function type", generate the
@@ -109,9 +106,7 @@ affix_data_type (param)
    of empty parens here.  */
 
 static const char *
    of empty parens here.  */
 
 static const char *
-gen_formal_list_for_type (fntype, style)
-     tree fntype;
-     formals_style style;
+gen_formal_list_for_type (tree fntype, formals_style style)
 {
   const char *formal_list = "";
   tree formal_type;
 {
   const char *formal_list = "";
   tree formal_type;
@@ -125,7 +120,7 @@ gen_formal_list_for_type (fntype, style)
       const char *this_type;
 
       if (*formal_list)
       const char *this_type;
 
       if (*formal_list)
-        formal_list = concat (formal_list, ", ", NULL);
+       formal_list = concat (formal_list, ", ", NULL);
 
       this_type = gen_type ("", TREE_VALUE (formal_type), ansi);
       formal_list
 
       this_type = gen_type ("", TREE_VALUE (formal_type), ansi);
       formal_list
@@ -168,47 +163,24 @@ gen_formal_list_for_type (fntype, style)
 
   if (!*formal_list)
     {
 
   if (!*formal_list)
     {
-      if (TYPE_ARG_TYPES (fntype))
-        /* assert (TREE_VALUE (TYPE_ARG_TYPES (fntype)) == void_type_node);  */
-        formal_list = "void";
+      if (prototype_p (fntype))
+       /* assert (TREE_VALUE (TYPE_ARG_TYPES (fntype)) == void_type_node);  */
+       formal_list = "void";
       else
       else
-        formal_list = "/* ??? */";
+       formal_list = "/* ??? */";
     }
   else
     {
       /* If there were at least some parameters, and if the formals-types-list
     }
   else
     {
       /* If there were at least some parameters, and if the formals-types-list
-         petered out to a NULL (i.e. without being terminated by a
-         void_type_node) then we need to tack on an ellipsis.  */
+        petered out to a NULL (i.e. without being terminated by a
+        void_type_node) then we need to tack on an ellipsis.  */
       if (!formal_type)
       if (!formal_type)
-        formal_list = concat (formal_list, ", ...", NULL);
+       formal_list = concat (formal_list, ", ...", NULL);
     }
 
   return concat (" (", formal_list, ")", NULL);
 }
 
     }
 
   return concat (" (", formal_list, ")", NULL);
 }
 
-/* For the generation of an ANSI prototype for a function definition, we have
-   to look at the formal parameter list of the function's own "type" to
-   determine if the function's formal parameter list should end with an
-   ellipsis.  Given a tree node, the following function will return non-zero
-   if the "function type" parameter list should end with an ellipsis.  */
-
-static int
-deserves_ellipsis (fntype)
-     tree fntype;
-{
-  tree formal_type;
-
-  formal_type = TYPE_ARG_TYPES (fntype);
-  while (formal_type && TREE_VALUE (formal_type) != void_type_node)
-    formal_type = TREE_CHAIN (formal_type);
-
-  /* If there were at least some parameters, and if the formals-types-list
-     petered out to a NULL (i.e. without being terminated by a void_type_node)
-     then we need to tack on an ellipsis.  */
-
-  return (!formal_type && TYPE_ARG_TYPES (fntype));
-}
-
 /* Generate a parameter list for a function definition (in some given style).
 
    Note that this routine has to be separate (and different) from the code that
 /* Generate a parameter list for a function definition (in some given style).
 
    Note that this routine has to be separate (and different) from the code that
@@ -229,9 +201,7 @@ deserves_ellipsis (fntype)
    function formal parameter list.  */
 
 static const char *
    function formal parameter list.  */
 
 static const char *
-gen_formal_list_for_func_def (fndecl, style)
-     tree fndecl;
-     formals_style style;
+gen_formal_list_for_func_def (tree fndecl, formals_style style)
 {
   const char *formal_list = "";
   tree formal_decl;
 {
   const char *formal_list = "";
   tree formal_decl;
@@ -242,20 +212,20 @@ gen_formal_list_for_func_def (fndecl, style)
       const char *this_formal;
 
       if (*formal_list && ((style == ansi) || (style == k_and_r_names)))
       const char *this_formal;
 
       if (*formal_list && ((style == ansi) || (style == k_and_r_names)))
-        formal_list = concat (formal_list, ", ", NULL);
+       formal_list = concat (formal_list, ", ", NULL);
       this_formal = gen_decl (formal_decl, 0, style);
       if (style == k_and_r_decls)
       this_formal = gen_decl (formal_decl, 0, style);
       if (style == k_and_r_decls)
-        formal_list = concat (formal_list, this_formal, "; ", NULL);
+       formal_list = concat (formal_list, this_formal, "; ", NULL);
       else
       else
-        formal_list = concat (formal_list, this_formal, NULL);
+       formal_list = concat (formal_list, this_formal, NULL);
       formal_decl = TREE_CHAIN (formal_decl);
     }
   if (style == ansi)
     {
       if (!DECL_ARGUMENTS (fndecl))
       formal_decl = TREE_CHAIN (formal_decl);
     }
   if (style == ansi)
     {
       if (!DECL_ARGUMENTS (fndecl))
-        formal_list = concat (formal_list, "void", NULL);
-      if (deserves_ellipsis (TREE_TYPE (fndecl)))
-        formal_list = concat (formal_list, ", ...", NULL);
+       formal_list = concat (formal_list, "void", NULL);
+      if (stdarg_p (TREE_TYPE (fndecl)))
+       formal_list = concat (formal_list, ", ...", NULL);
     }
   if ((style == ansi) || (style == k_and_r_names))
     formal_list = concat (" (", formal_list, ")", NULL);
     }
   if ((style == ansi) || (style == k_and_r_names))
     formal_list = concat (" (", formal_list, ")", NULL);
@@ -304,10 +274,7 @@ gen_formal_list_for_func_def (fndecl, style)
    string onto the returned "seed".  */
 
 static const char *
    string onto the returned "seed".  */
 
 static const char *
-gen_type (ret_val, t, style)
-     const char *ret_val;
-     tree t;
-     formals_style style;
+gen_type (const char *ret_val, tree t, formals_style style)
 {
   tree chain_p;
 
 {
   tree chain_p;
 
@@ -317,23 +284,23 @@ gen_type (ret_val, t, style)
   else
     {
       switch (TREE_CODE (t))
   else
     {
       switch (TREE_CODE (t))
-        {
-        case POINTER_TYPE:
-          if (TYPE_READONLY (t))
-            ret_val = concat ("const ", ret_val, NULL);
-          if (TYPE_VOLATILE (t))
-            ret_val = concat ("volatile ", ret_val, NULL);
+       {
+       case POINTER_TYPE:
+         if (TYPE_READONLY (t))
+           ret_val = concat ("const ", ret_val, NULL);
+         if (TYPE_VOLATILE (t))
+           ret_val = concat ("volatile ", ret_val, NULL);
 
 
-          ret_val = concat ("*", ret_val, NULL);
+         ret_val = concat ("*", ret_val, NULL);
 
          if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
            ret_val = concat ("(", ret_val, ")", NULL);
 
 
          if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE || TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
            ret_val = concat ("(", ret_val, ")", NULL);
 
-          ret_val = gen_type (ret_val, TREE_TYPE (t), style);
+         ret_val = gen_type (ret_val, TREE_TYPE (t), style);
 
 
-          return ret_val;
+         return ret_val;
 
 
-        case ARRAY_TYPE:
+       case ARRAY_TYPE:
          if (!COMPLETE_TYPE_P (t) || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
            ret_val = gen_type (concat (ret_val, "[]", NULL),
                                TREE_TYPE (t), style);
          if (!COMPLETE_TYPE_P (t) || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
            ret_val = gen_type (concat (ret_val, "[]", NULL),
                                TREE_TYPE (t), style);
@@ -348,23 +315,23 @@ gen_type (ret_val, t, style)
              ret_val = gen_type (concat (ret_val, buff, NULL),
                                  TREE_TYPE (t), style);
            }
              ret_val = gen_type (concat (ret_val, buff, NULL),
                                  TREE_TYPE (t), style);
            }
-          break;
+         break;
 
 
-        case FUNCTION_TYPE:
-          ret_val = gen_type (concat (ret_val,
+       case FUNCTION_TYPE:
+         ret_val = gen_type (concat (ret_val,
                                      gen_formal_list_for_type (t, style),
                                      NULL),
                              TREE_TYPE (t), style);
                                      gen_formal_list_for_type (t, style),
                                      NULL),
                              TREE_TYPE (t), style);
-          break;
+         break;
 
 
-        case IDENTIFIER_NODE:
-          data_type = IDENTIFIER_POINTER (t);
-          break;
+       case IDENTIFIER_NODE:
+         data_type = IDENTIFIER_POINTER (t);
+         break;
 
        /* The following three cases are complicated by the fact that a
 
        /* The following three cases are complicated by the fact that a
-           user may do something really stupid, like creating a brand new
-           "anonymous" type specification in a formal argument list (or as
-           part of a function return type specification).  For example:
+          user may do something really stupid, like creating a brand new
+          "anonymous" type specification in a formal argument list (or as
+          part of a function return type specification).  For example:
 
                int f (enum { red, green, blue } color);
 
 
                int f (enum { red, green, blue } color);
 
@@ -372,7 +339,7 @@ gen_type (ret_val, t, style)
           to represent the (anonymous) type.  Thus, we have to generate the
           whole darn type specification.  Yuck!  */
 
           to represent the (anonymous) type.  Thus, we have to generate the
           whole darn type specification.  Yuck!  */
 
-        case RECORD_TYPE:
+       case RECORD_TYPE:
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
@@ -391,7 +358,7 @@ gen_type (ret_val, t, style)
          data_type = concat ("struct ", data_type, NULL);
          break;
 
          data_type = concat ("struct ", data_type, NULL);
          break;
 
-        case UNION_TYPE:
+       case UNION_TYPE:
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
@@ -410,7 +377,7 @@ gen_type (ret_val, t, style)
          data_type = concat ("union ", data_type, NULL);
          break;
 
          data_type = concat ("union ", data_type, NULL);
          break;
 
-        case ENUMERAL_TYPE:
+       case ENUMERAL_TYPE:
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
          if (TYPE_NAME (t))
            data_type = IDENTIFIER_POINTER (TYPE_NAME (t));
          else
@@ -430,33 +397,34 @@ gen_type (ret_val, t, style)
          data_type = concat ("enum ", data_type, NULL);
          break;
 
          data_type = concat ("enum ", data_type, NULL);
          break;
 
-        case TYPE_DECL:
-          data_type = IDENTIFIER_POINTER (DECL_NAME (t));
-          break;
-        case INTEGER_TYPE:
-          data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
-          /* Normally, `unsigned' is part of the deal.  Not so if it comes
-            with a type qualifier.  */
-          if (TREE_UNSIGNED (t) && TYPE_QUALS (t))
-           data_type = concat ("unsigned ", data_type, NULL);
+       case TYPE_DECL:
+         data_type = IDENTIFIER_POINTER (DECL_NAME (t));
          break;
 
          break;
 
-        case REAL_TYPE:
-          data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
-          break;
+       case INTEGER_TYPE:
+       case FIXED_POINT_TYPE:
+         data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+         /* Normally, `unsigned' is part of the deal.  Not so if it comes
+            with a type qualifier.  */
+         if (TYPE_UNSIGNED (t) && TYPE_QUALS (t))
+           data_type = concat ("unsigned ", data_type, NULL);
+         break;
 
 
-        case VOID_TYPE:
-          data_type = "void";
-          break;
+       case REAL_TYPE:
+         data_type = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (t)));
+         break;
+
+       case VOID_TYPE:
+         data_type = "void";
+         break;
 
        case ERROR_MARK:
          data_type = "[ERROR]";
          break;
 
 
        case ERROR_MARK:
          data_type = "[ERROR]";
          break;
 
-        default:
-          abort ();
-        }
+       default:
+         gcc_unreachable ();
+       }
     }
   if (TYPE_READONLY (t))
     ret_val = concat ("const ", ret_val, NULL);
     }
   if (TYPE_READONLY (t))
     ret_val = concat ("const ", ret_val, NULL);
@@ -472,16 +440,13 @@ gen_type (ret_val, t, style)
 
    The given entity may be either a variable or a function.
 
 
    The given entity may be either a variable or a function.
 
-   If the "is_func_definition" parameter is non-zero, assume that the thing
+   If the "is_func_definition" parameter is nonzero, assume that the thing
    we are generating a declaration for is a FUNCTION_DECL node which is
    associated with a function definition.  In this case, we can assume that
    an attached list of DECL nodes for function formal arguments is present.  */
 
 static const char *
    we are generating a declaration for is a FUNCTION_DECL node which is
    associated with a function definition.  In this case, we can assume that
    an attached list of DECL nodes for function formal arguments is present.  */
 
 static const char *
-gen_decl (decl, is_func_definition, style)
-     tree decl;
-     int is_func_definition;
-     formals_style style;
+gen_decl (tree decl, int is_func_definition, formals_style style)
 {
   const char *ret_val;
 
 {
   const char *ret_val;
 
@@ -529,11 +494,11 @@ gen_decl (decl, is_func_definition, style)
                        NULL);
 
       /* Since we have already added in the formals list stuff, here we don't
                        NULL);
 
       /* Since we have already added in the formals list stuff, here we don't
-         add the whole "type" of the function we are considering (which
-         would include its parameter-list info), rather, we only add in
-         the "type" of the "type" of the function, which is really just
-         the return-type of the function (and does not include the parameter
-         list info).  */
+        add the whole "type" of the function we are considering (which
+        would include its parameter-list info), rather, we only add in
+        the "type" of the "type" of the function, which is really just
+        the return-type of the function (and does not include the parameter
+        list info).  */
 
       ret_val = gen_type (ret_val, TREE_TYPE (TREE_TYPE (decl)), style);
     }
 
       ret_val = gen_type (ret_val, TREE_TYPE (TREE_TYPE (decl)), style);
     }
@@ -542,7 +507,7 @@ gen_decl (decl, is_func_definition, style)
 
   ret_val = affix_data_type (ret_val);
 
 
   ret_val = affix_data_type (ret_val);
 
-  if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
+  if (TREE_CODE (decl) != FUNCTION_DECL && C_DECL_REGISTER (decl))
     ret_val = concat ("register ", ret_val, NULL);
   if (TREE_PUBLIC (decl))
     ret_val = concat ("extern ", ret_val, NULL);
     ret_val = concat ("register ", ret_val, NULL);
   if (TREE_PUBLIC (decl))
     ret_val = concat ("extern ", ret_val, NULL);
@@ -559,20 +524,18 @@ extern FILE *aux_info_file;
    function definition (even the implicit ones).  */
 
 void
    function definition (even the implicit ones).  */
 
 void
-gen_aux_info_record (fndecl, is_definition, is_implicit, is_prototyped)
-     tree fndecl;
-     int is_definition;
-     int is_implicit;
-     int is_prototyped;
+gen_aux_info_record (tree fndecl, int is_definition, int is_implicit,
+                    int is_prototyped)
 {
   if (flag_gen_aux_info)
     {
       static int compiled_from_record = 0;
 {
   if (flag_gen_aux_info)
     {
       static int compiled_from_record = 0;
+      expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (fndecl));
 
       /* Each output .X file must have a header line.  Write one now if we
         have not yet done so.  */
 
 
       /* Each output .X file must have a header line.  Write one now if we
         have not yet done so.  */
 
-      if (! compiled_from_record++)
+      if (!compiled_from_record++)
        {
          /* The first line tells which directory file names are relative to.
             Currently, -aux-info works only for files in the working
        {
          /* The first line tells which directory file names are relative to.
             Currently, -aux-info works only for files in the working
@@ -583,8 +546,7 @@ gen_aux_info_record (fndecl, is_definition, is_implicit, is_prototyped)
       /* Write the actual line of auxiliary info.  */
 
       fprintf (aux_info_file, "/* %s:%d:%c%c */ %s;",
       /* Write the actual line of auxiliary info.  */
 
       fprintf (aux_info_file, "/* %s:%d:%c%c */ %s;",
-              DECL_SOURCE_FILE (fndecl),
-              DECL_SOURCE_LINE (fndecl),
+              xloc.file, xloc.line,
               (is_implicit) ? 'I' : (is_prototyped) ? 'N' : 'O',
               (is_definition) ? 'F' : 'C',
               gen_decl (fndecl, is_definition, ansi));
               (is_implicit) ? 'I' : (is_prototyped) ? 'N' : 'O',
               (is_definition) ? 'F' : 'C',
               gen_decl (fndecl, is_definition, ansi));