OSDN Git Service

* decl.c (init_decl_processing): Remove duplicate decl of
[pf3gnuchains/gcc-fork.git] / gcc / scan-decls.c
index 13bfca3..13a09ac 100644 (file)
@@ -1,5 +1,5 @@
 /* scan-decls.c - Extracts declarations from cpp output.
-   Copyright (C) 1993, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1995, 97-99, 2000 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify it
 under the terms of the GNU General Public License as published by the
@@ -13,15 +13,16 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
-Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
    Written by Per Bothner <bothner@cygnus.com>, July 1993.  */
 
-#include <stdio.h>
-#include <ctype.h>
 #include "hconfig.h"
+#include "system.h"
 #include "cpplib.h"
+#include "scan.h"
+
+static void skip_to_closing_brace PARAMS ((cpp_reader *));
 
 int brace_nesting = 0;
 
@@ -78,20 +79,21 @@ Here dname is the actual name being declared.
 int
 scan_decls (pfile, argc, argv)
      cpp_reader *pfile;
-     int argc;
-     char**argv;
+     int argc ATTRIBUTE_UNUSED;
+     char **argv ATTRIBUTE_UNUSED;
 {
   int saw_extern, saw_inline;
-  int old_written;
+  int start_written;
   /* If declarator_start is non-zero, it marks the start of the current
      declarator.  If it is zero, we are either still parsing the
-     decl-specs, or prev_id_start marks the start of the declarator. */
+     decl-specs, or prev_id_start marks the start of the declarator.  */
   int declarator_start;
-  int prev_id_start, prev_id_end;
+  int prev_id_start, prev_id_end = 0;
   enum cpp_token token;
 
  new_statement:
   CPP_SET_WRITTEN (pfile, 0);
+  start_written = 0;
   token = cpp_get_token (pfile);
 
  handle_statement:
@@ -123,13 +125,10 @@ scan_decls (pfile, argc, argv)
   declarator_start = 0;
   for (;;)
     {
-      int start_written = CPP_WRITTEN (pfile);
-      token = cpp_get_token (pfile);
-    handle_token:
       switch (token)
        {
        case CPP_LPAREN:
-         /* Looks like this is the start of a formal parameter list. */
+         /* Looks like this is the start of a formal parameter list.  */
          if (prev_id_start)
            {
              int nesting = 1;
@@ -172,7 +171,7 @@ scan_decls (pfile, argc, argv)
            }
          break;
        case CPP_OTHER:
-         if (CPP_WRITTEN (pfile) == start_written + 1
+         if (CPP_WRITTEN (pfile) == (size_t) start_written + 1
              && (CPP_PWRITTEN (pfile)[-1] == '*'
                  || CPP_PWRITTEN (pfile)[-1] == '&'))
            declarator_start = start_written;
@@ -188,11 +187,13 @@ scan_decls (pfile, argc, argv)
                                 pfile->token_buffer,
                                 prev_id_start);
            }
-         /* ... fall through ... */
+         /* ... fall through ...  */
        maybe_handle_comma:
          if (token != CPP_COMMA)
            goto new_statement;
+#if 0
        handle_comma:
+#endif
          /* Handle multiple declarators in a single declaration,
             as in:  extern char *strcpy (), *strcat (), ... ; */
          if (declarator_start == 0)
@@ -226,28 +227,31 @@ scan_decls (pfile, argc, argv)
                    }
                }
              else
-               goto handle_token;
+               continue;
              break;
            }
-         /* This may be the name of a variable or function. */
+         /* This may be the name of a variable or function.  */
          prev_id_start = start_written;
          prev_id_end = CPP_WRITTEN (pfile);
          break;
 
        case CPP_EOF:
-         return;  /* ??? FIXME */
+         return 0;
 
        case CPP_LBRACE:  case CPP_RBRACE:  case CPP_DIRECTIVE:
          goto new_statement;  /* handle_statement? */
          
        case CPP_HSPACE:  case CPP_VSPACE:  case CPP_COMMENT:  case CPP_POP:
-         /* Skip initial white space. */
+         /* Skip initial white space.  */
          if (start_written == 0)
            CPP_SET_WRITTEN (pfile, 0);
          break;
 
         default:
-         prev_id_start = NULL;
+         prev_id_start = 0;
        }
+
+      start_written = CPP_WRITTEN (pfile);
+      token = cpp_get_token (pfile);
     }
 }