OSDN Git Service

(i386_return_pops_args): Libcalls ignore TARGET_RTD.
[pf3gnuchains/gcc-fork.git] / gcc / c-aux-info.c
index 16c3aec..429601f 100644 (file)
@@ -1,10 +1,8 @@
 /* Generate information regarding function declarations and definitions based
    on information stored in GCC's tree structure.  This code implements the
-   -fgen-aux-info option.
-
-   This code was written by Ron Guilmette (rfg@mcc.com).
-
-   Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+   -aux-info option.
+   Copyright (C) 1989, 1991, 1994, 1995 Free Software Foundation, Inc.
+   Contributed by Ron Guilmette (rfg@segfault.us.com).
 
 This file is part of GNU CC.
 
@@ -20,21 +18,16 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
 
 #include <stdio.h>
-#include <sys/param.h>
-#include <errno.h>
 #include "config.h"
 #include "flags.h"
 #include "tree.h"
 #include "c-tree.h"
 
-#ifndef errno
-extern int errno;
-#endif
-
-extern char* xmalloc ();
+extern char *xmalloc ();
 
 enum formals_style_enum {
   ansi,
@@ -44,40 +37,26 @@ enum formals_style_enum {
 typedef enum formals_style_enum formals_style;
 
 
-static chardata_type;
+static char *data_type;
 
-static char * concat ();
-static char * concat3 ();
-static char * gen_formal_list_for_type ();
-static int    deserves_ellipsis ();
-static char * gen_formal_list_for_func_def ();
-static char * gen_type ();
-static char * gen_decl ();
+static char *concat ();
+static char *concat3 ();
+static char *gen_formal_list_for_type ();
+static int   deserves_ellipsis ();
+static char *gen_formal_list_for_func_def ();
+static char *gen_type ();
+static char *gen_decl ();
 void   gen_aux_info_record ();
-
-/* Virtually every UN*X system now in common use (except for pre-4.3-tahoe
-   BSD systems) now provides getcwd as called for by POSIX.  Allow for
-   the few exceptions to the general rule here.  */
-
-#if !(defined (USG) || defined (VMS))
-extern char *getwd ();
-#define getcwd(buf,len) getwd(buf)
-#define GUESSPATHLEN (MAXPATHLEN + 1)
-#else /* (defined (USG) || defined (VMS)) */
-extern char *getcwd ();
-/* We actually use this as a starting point, not a limit.  */
-#define GUESSPATHLEN 100
-#endif /* (defined (USG) || defined (VMS)) */
 \f
 /*  Take two strings and mash them together into a newly allocated area.  */
 
-static char*
+static char *
 concat (s1, s2)
-     chars1;
-     chars2;
+     char *s1;
+     char *s2;
 {
   int size1, size2;
-  charret_val;
+  char *ret_val;
 
   if (!s1)
     s1 = "";
@@ -94,14 +73,14 @@ concat (s1, s2)
 
 /*  Take three strings and mash them together into a newly allocated area.  */
 
-static char*
+static char *
 concat3 (s1, s2, s3)
-     chars1;
-     chars2;
-     chars3;
+     char *s1;
+     char *s2;
+     char *s3;
 {
   int size1, size2, size3;
-  charret_val;
+  char *ret_val;
 
   if (!s1)
     s1 = "";
@@ -134,7 +113,7 @@ concat3 (s1, s2, s3)
    `const char *foo;' and *not* `char const *foo;' so we try to create types
    that look as expected.  */
 
-static char*
+static char *
 affix_data_type (type_or_decl)
      char *type_or_decl;
 {
@@ -146,12 +125,12 @@ affix_data_type (type_or_decl)
 
   for (;;)
     {
-      if (!strncmp (p, "volatile", 8))
+      if (!strncmp (p, "volatile ", 9))
         {
           p += 9;
           continue;
         }
-      if (!strncmp (p, "const", 5))
+      if (!strncmp (p, "const ", 6))
         {
           p += 6;
           continue;
@@ -177,14 +156,14 @@ affix_data_type (type_or_decl)
    this function type.  Return the whole formal parameter list (including
    a pair of surrounding parens) as a string.   Note that if the style
    we are currently aiming for is non-ansi, then we just return a pair
-   of empty parens here. */
+   of empty parens here.  */
 
-static char*
+static char *
 gen_formal_list_for_type (fntype, style)
      tree fntype;
      formals_style style;
 {
-  charformal_list = "";
+  char *formal_list = "";
   tree formal_type;
 
   if (style != ansi)
@@ -193,7 +172,7 @@ gen_formal_list_for_type (fntype, style)
   formal_type = TYPE_ARG_TYPES (fntype);
   while (formal_type && TREE_VALUE (formal_type) != void_type_node)
     {
-      charthis_type;
+      char *this_type;
 
       if (*formal_list)
         formal_list = concat (formal_list, ", ");
@@ -230,7 +209,7 @@ gen_formal_list_for_type (fntype, style)
      to output the "void" verbatim, and that what we do.  In the former case,
      we do our best to give protoize something nice to insert.
 
-     This "something nice" should be something that is still legal (when
+     This "something nice" should be something that is still valid (when
      re-compiled) but something that can clearly indicate to the user that
      more typing information (for the parameter list) should be added (by
      hand) at some convenient moment.
@@ -299,12 +278,12 @@ deserves_ellipsis (fntype)
    This routine returns a string which is the source form for the entire
    function formal parameter list.  */
 
-static char*
+static char *
 gen_formal_list_for_func_def (fndecl, style)
      tree fndecl;
      formals_style style;
 {
-  charformal_list = "";
+  char *formal_list = "";
   tree formal_decl;
 
   formal_decl = DECL_ARGUMENTS (fndecl);
@@ -374,9 +353,9 @@ gen_formal_list_for_func_def (fndecl, style)
    to do at this point is for the initial caller to prepend the "data_type"
    string onto the returned "seed".  */
 
-static char*
+static char *
 gen_type (ret_val, t, style)
-     charret_val;
+     char *ret_val;
      tree t;
      formals_style style;
 {
@@ -404,7 +383,18 @@ gen_type (ret_val, t, style)
           return ret_val;
 
         case ARRAY_TYPE:
-          ret_val = gen_type (concat (ret_val, "[]"), TREE_TYPE (t), style);
+         if (TYPE_SIZE (t) == 0 || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
+           ret_val = gen_type (concat (ret_val, "[]"), TREE_TYPE (t), style);
+         else if (int_size_in_bytes (t) == 0)
+           ret_val = gen_type (concat (ret_val, "[0]"), TREE_TYPE (t), style);
+         else
+           {
+             int size = (int_size_in_bytes (t) / int_size_in_bytes (TREE_TYPE (t)));
+             char buff[10];
+             sprintf (buff, "[%d]", size);
+             ret_val = gen_type (concat (ret_val, buff),
+                                 TREE_TYPE (t), style);
+           }
           break;
 
         case FUNCTION_TYPE:
@@ -502,6 +492,10 @@ gen_type (ret_val, t, style)
           data_type = "void";
           break;
 
+       case ERROR_MARK:
+         data_type = "[ERROR]";
+         break;
+
         default:
           abort ();
         }
@@ -523,14 +517,13 @@ gen_type (ret_val, t, style)
    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 char*
+static char *
 gen_decl (decl, is_func_definition, style)
      tree decl;
      int is_func_definition;
      formals_style style;
 {
-  char* ret_val;
-  char* outer_modifier = "";
+  char *ret_val;
 
   if (DECL_NAME (decl))
     ret_val = IDENTIFIER_POINTER (DECL_NAME (decl));
@@ -588,7 +581,7 @@ gen_decl (decl, is_func_definition, style)
 
   ret_val = affix_data_type (ret_val);
 
-  if (TREE_REGDECL (decl))
+  if (TREE_CODE (decl) != FUNCTION_DECL && DECL_REGISTER (decl))
     ret_val = concat ("register ", ret_val);
   if (TREE_PUBLIC (decl))
     ret_val = concat ("extern ", ret_val);
@@ -598,7 +591,7 @@ gen_decl (decl, is_func_definition, style)
   return ret_val;
 }
 
-extern FILEaux_info_file;
+extern FILE *aux_info_file;
 
 /* Generate and write a new line of info to the aux-info (.X) file.  This
    routine is called once for each function declaration, and once for each
@@ -620,24 +613,10 @@ gen_aux_info_record (fndecl, is_definition, is_implicit, is_prototyped)
 
       if (! compiled_from_record++)
        {
-         int size;
-         char *wd;
-         char *value;
-
-         /* Read the working directory, avoiding arbitrary limit.  */
-         size = GUESSPATHLEN;
-         while (1)
-           {
-             wd = (char *) xmalloc (size);
-             value = getcwd (wd, size);
-             if (value != 0 || errno != ERANGE)
-               break;
-             free (wd);
-             size *= 2;
-           }
-
-         if (value != 0)
-           fprintf (aux_info_file, "/* compiled from: %s */\n", wd);
+         /* The first line tells which directory file names are relative to.
+            Currently, -aux-info works only for files in the working
+            directory, so just use a `.' as a placeholder for now.  */
+         fprintf (aux_info_file, "/* compiled from: . */\n");
        }
 
       /* Write the actual line of auxiliary info.  */