OSDN Git Service

* gcc.c-torture/execute/20000412-1.c: Reduce some more.
[pf3gnuchains/gcc-fork.git] / gcc / c-aux-info.c
index d86d445..f3b375f 100644 (file)
@@ -1,7 +1,8 @@
 /* Generate information regarding function declarations and definitions based
    on information stored in GCC's tree structure.  This code implements the
    -aux-info option.
-   Copyright (C) 1989, 91, 94, 95, 97, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1989, 1991, 1994, 1995, 1997, 1998,
+   1999, 2000 Free Software Foundation, Inc.
    Contributed by Ron Guilmette (rfg@segfault.us.com).
 
 This file is part of GNU CC.
@@ -23,6 +24,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
 #include "system.h"
+#include "toplev.h"
 #include "flags.h"
 #include "tree.h"
 #include "c-tree.h"
@@ -35,76 +37,15 @@ enum formals_style_enum {
 typedef enum formals_style_enum formals_style;
 
 
-static char *data_type;
+static const char *data_type;
 
-static char *affix_data_type           PROTO((char *));
-static char *gen_formal_list_for_type  PROTO((tree, formals_style));
-static int   deserves_ellipsis         PROTO((tree));
-static char *gen_formal_list_for_func_def PROTO((tree, formals_style));
-static char *gen_type                  PROTO((char *, tree, formals_style));
-static char *gen_decl                  PROTO((tree, int, formals_style));
+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));
 \f
-/* Concatenate a sequence of strings, returning the result.
-
-   This function is based on the one in libiberty.  */
-
-/* This definition will conflict with the one from prefix.c in
-   libcpp.a when linking cc1 and cc1obj.  So only provide it if we are
-   not using libcpp.a */
-#ifndef USE_CPPLIB
-char *
-concat VPROTO((const char *first, ...))
-{
-  register int length;
-  register char *newstr;
-  register char *end;
-  register const char *arg;
-  va_list args;
-#ifndef ANSI_PROTOTYPES
-  const char *first;
-#endif
-
-  /* First compute the size of the result and get sufficient memory.  */
-
-  VA_START (args, first);
-#ifndef ANSI_PROTOTYPES
-  first = va_arg (args, const char *);
-#endif
-
-  arg = first;
-  length = 0;
-
-  while (arg != 0)
-    {
-      length += strlen (arg);
-      arg = va_arg (args, const char *);
-    }
-
-  newstr = (char *) malloc (length + 1);
-  va_end (args);
-
-  /* Now copy the individual pieces to the result string.  */
-
-  VA_START (args, first);
-#ifndef ANSI_PROTOTYPES
-  first = va_arg (args, char *);
-#endif
-
-  end = newstr;
-  arg = first;
-  while (arg != 0)
-    {
-      while (*arg)
-       *end++ = *arg++;
-      arg = va_arg (args, const char *);
-    }
-  *end = '\000';
-  va_end (args);
-
-  return (newstr);
-}
-#endif /* ! USE_CPPLIB */
-
 /* Given a string representing an entire type or an entire declaration
    which only lacks the actual "data-type" specifier (at its left end),
    affix the data-type specifier to the left end of the given type
@@ -120,13 +61,16 @@ concat VPROTO((const char *first, ...))
    that look as expected.  */
 
 static char *
-affix_data_type (type_or_decl)
-     char *type_or_decl;
+affix_data_type (param)
+     const char *param;
 {
+  char *type_or_decl = (char *) alloca (strlen (param) + 1);
   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 (;;)
@@ -164,12 +108,12 @@ affix_data_type (type_or_decl)
    we are currently aiming for is non-ansi, then we just return a pair
    of empty parens here.  */
 
-static char *
+static const char *
 gen_formal_list_for_type (fntype, style)
      tree fntype;
      formals_style style;
 {
-  char *formal_list = "";
+  const char *formal_list = "";
   tree formal_type;
 
   if (style != ansi)
@@ -178,7 +122,7 @@ gen_formal_list_for_type (fntype, style)
   formal_type = TYPE_ARG_TYPES (fntype);
   while (formal_type && TREE_VALUE (formal_type) != void_type_node)
     {
-      char *this_type;
+      const char *this_type;
 
       if (*formal_list)
         formal_list = concat (formal_list, ", ", NULL_PTR);
@@ -284,18 +228,18 @@ deserves_ellipsis (fntype)
    This routine returns a string which is the source form for the entire
    function formal parameter list.  */
 
-static char *
+static const char *
 gen_formal_list_for_func_def (fndecl, style)
      tree fndecl;
      formals_style style;
 {
-  char *formal_list = "";
+  const char *formal_list = "";
   tree formal_decl;
 
   formal_decl = DECL_ARGUMENTS (fndecl);
   while (formal_decl)
     {
-      char *this_formal;
+      const char *this_formal;
 
       if (*formal_list && ((style == ansi) || (style == k_and_r_names)))
         formal_list = concat (formal_list, ", ", NULL_PTR);
@@ -359,9 +303,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 const char *
 gen_type (ret_val, t, style)
-     char *ret_val;
+     const char *ret_val;
      tree t;
      formals_style style;
 {
@@ -390,7 +334,7 @@ gen_type (ret_val, t, style)
           return ret_val;
 
         case ARRAY_TYPE:
-         if (TYPE_SIZE (t) == 0 || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
+         if (!COMPLETE_TYPE_P (t) || TREE_CODE (TYPE_SIZE (t)) != INTEGER_CST)
            ret_val = gen_type (concat (ret_val, "[]", NULL_PTR),
                                TREE_TYPE (t), style);
          else if (int_size_in_bytes (t) == 0)
@@ -533,13 +477,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 const char *
 gen_decl (decl, is_func_definition, style)
      tree decl;
      int is_func_definition;
      formals_style style;
 {
-  char *ret_val;
+  const char *ret_val;
 
   if (DECL_NAME (decl))
     ret_val = IDENTIFIER_POINTER (DECL_NAME (decl));