OSDN Git Service

* c-typeck.c (common_type): Correct comment.
[pf3gnuchains/gcc-fork.git] / gcc / read-rtl.c
index fd17bd0..d17235f 100644 (file)
@@ -1,5 +1,6 @@
 /* RTL reader for GCC.
-   Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002
+   Copyright (C) 1987, 1988, 1991, 1994, 1997, 1998, 1999, 2000, 2001, 2002,
+   2003, 2004
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -29,18 +30,18 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 static htab_t md_constants;
 
-static void fatal_with_file_and_line PARAMS ((FILE *, const char *, ...))
+static void fatal_with_file_and_line (FILE *, const char *, ...)
   ATTRIBUTE_PRINTF_2 ATTRIBUTE_NORETURN;
-static void fatal_expected_char PARAMS ((FILE *, int, int)) ATTRIBUTE_NORETURN;
-static void read_name          PARAMS ((char *, FILE *));
-static char *read_string       PARAMS ((struct obstack *, FILE *, int));
-static char *read_quoted_string        PARAMS ((struct obstack *, FILE *));
-static char *read_braced_string        PARAMS ((struct obstack *, FILE *));
-static void read_escape                PARAMS ((struct obstack *, FILE *));
-static hashval_t def_hash      PARAMS ((const void *));
-static int def_name_eq_p PARAMS ((const void *, const void *));
-static void read_constants PARAMS ((FILE *infile, char *tmp_char));
-static void validate_const_int PARAMS ((FILE *, const char *));
+static void fatal_expected_char (FILE *, int, int) ATTRIBUTE_NORETURN;
+static void read_name (char *, FILE *);
+static char *read_string (struct obstack *, FILE *, int);
+static char *read_quoted_string (struct obstack *, FILE *);
+static char *read_braced_string (struct obstack *, FILE *);
+static void read_escape (struct obstack *, FILE *);
+static hashval_t def_hash (const void *);
+static int def_name_eq_p (const void *, const void *);
+static void read_constants (FILE *infile, char *tmp_char);
+static void validate_const_int (FILE *, const char *);
 
 /* Subroutines of read_rtx.  */
 
@@ -87,9 +88,7 @@ fatal_with_file_and_line (FILE *infile, const char *msg, ...)
    invalid data.  */
 
 static void
-fatal_expected_char (infile, expected_c, actual_c)
-     FILE *infile;
-     int expected_c, actual_c;
+fatal_expected_char (FILE *infile, int expected_c, int actual_c)
 {
   fatal_with_file_and_line (infile, "expected character `%c', found `%c'",
                            expected_c, actual_c);
@@ -101,8 +100,7 @@ fatal_expected_char (infile, expected_c, actual_c)
    Tools such as genflags use this function.  */
 
 int
-read_skip_spaces (infile)
-     FILE *infile;
+read_skip_spaces (FILE *infile)
 {
   int c;
 
@@ -154,9 +152,7 @@ read_skip_spaces (infile)
    It is terminated by any of the punctuation chars of rtx printed syntax.  */
 
 static void
-read_name (str, infile)
-     char *str;
-     FILE *infile;
+read_name (char *str, FILE *infile)
 {
   char *p;
   int c;
@@ -207,9 +203,7 @@ read_name (str, infile)
 /* Subroutine of the string readers.  Handles backslash escapes.
    Caller has read the backslash, but not placed it into the obstack.  */
 static void
-read_escape (ob, infile)
-     struct obstack *ob;
-     FILE *infile;
+read_escape (struct obstack *ob, FILE *infile)
 {
   int c = getc (infile);
 
@@ -262,9 +256,7 @@ read_escape (ob, infile)
 /* Read a double-quoted string onto the obstack.  Caller has scanned
    the leading quote.  */
 static char *
-read_quoted_string (ob, infile)
-     struct obstack *ob;
-     FILE *infile;
+read_quoted_string (struct obstack *ob, FILE *infile)
 {
   int c;
 
@@ -292,17 +284,17 @@ read_quoted_string (ob, infile)
    scanned the leading brace.  Note that unlike quoted strings,
    the outermost braces _are_ included in the string constant.  */
 static char *
-read_braced_string (ob, infile)
-     struct obstack *ob;
-     FILE *infile;
+read_braced_string (struct obstack *ob, FILE *infile)
 {
   int c;
   int brace_depth = 1;  /* caller-processed */
+  unsigned long starting_read_rtx_lineno = read_rtx_lineno;
 
   obstack_1grow (ob, '{');
   while (brace_depth)
     {
       c = getc (infile); /* Read the string  */
+
       if (c == '\n')
        read_rtx_lineno++;
       else if (c == '{')
@@ -314,6 +306,10 @@ read_braced_string (ob, infile)
          read_escape (ob, infile);
          continue;
        }
+      else if (c == EOF)
+       fatal_with_file_and_line
+         (infile, "missing closing } for opening brace on line %lu",
+          starting_read_rtx_lineno);
 
       obstack_1grow (ob, c);
     }
@@ -327,10 +323,7 @@ read_braced_string (ob, infile)
    and dispatch to the appropriate string constant reader.  */
 
 static char *
-read_string (ob, infile, star_if_braced)
-     struct obstack *ob;
-     FILE *infile;
-     int star_if_braced;
+read_string (struct obstack *ob, FILE *infile, int star_if_braced)
 {
   char *stringbuf;
   int saw_paren = 0;
@@ -367,11 +360,10 @@ read_string (ob, infile, star_if_braced)
 /* Provide a version of a function to read a long long if the system does
    not provide one.  */
 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !defined(HAVE_ATOLL) && !defined(HAVE_ATOQ)
-HOST_WIDE_INT atoll PARAMS ((const char *));
+HOST_WIDE_INT atoll (const char *);
 
 HOST_WIDE_INT
-atoll (p)
-    const char *p;
+atoll (const char *p)
 {
   int neg = 0;
   HOST_WIDE_INT tmp_wide;
@@ -405,8 +397,7 @@ atoll (p)
 
 /* Given a constant definition, return a hash code for its name.  */
 static hashval_t
-def_hash (def)
-     const void *def;
+def_hash (const void *def)
 {
   unsigned result, i;
   const char *string = ((const struct md_constant *) def)->name;
@@ -418,8 +409,7 @@ def_hash (def)
 
 /* Given two constant definitions, return true if they have the same name.  */
 static int
-def_name_eq_p (def1, def2)
-     const void *def1, *def2;
+def_name_eq_p (const void *def1, const void *def2)
 {
   return ! strcmp (((const struct md_constant *) def1)->name,
                   ((const struct md_constant *) def2)->name);
@@ -429,9 +419,7 @@ def_name_eq_p (def1, def2)
    to read a name or number into.  Process a define_constants directive,
    starting with the optional space after the "define_constants".  */
 static void
-read_constants (infile, tmp_char)
-     FILE *infile;
-     char *tmp_char;
+read_constants (FILE *infile, char *tmp_char)
 {
   int c;
   htab_t defs;
@@ -487,18 +475,14 @@ read_constants (infile, tmp_char)
    a pointer a pointer to the constant definition and INFO.
    Stops when CALLBACK returns zero.  */
 void
-traverse_md_constants (callback, info)
-     htab_trav callback;
-     void *info;
+traverse_md_constants (htab_trav callback, void *info)
 {
   if (md_constants)
     htab_traverse (md_constants, callback, info);
 }
 
 static void
-validate_const_int (infile, string)
-     FILE *infile;
-     const char *string;
+validate_const_int (FILE *infile, const char *string)
 {
   const char *cp;
   int valid = 1;
@@ -523,8 +507,7 @@ validate_const_int (infile, string)
    the utilities gen*.c that construct C code from machine descriptions.  */
 
 rtx
-read_rtx (infile)
-     FILE *infile;
+read_rtx (FILE *infile)
 {
   int i, j;
   RTX_CODE tmp_code;
@@ -647,7 +630,7 @@ again:
          if (c != '[')
            fatal_expected_char (infile, '[', c);
 
-         /* add expressions to a list, while keeping a count */
+         /* Add expressions to a list, while keeping a count.  */
          obstack_init (&vector_stack);
          while ((c = read_skip_spaces (infile)) && c != ']')
            {
@@ -668,26 +651,28 @@ again:
        break;
 
       case 'S':
-       /* 'S' is an optional string: if a closeparen follows,
-          just store NULL for this element.  */
-       c = read_skip_spaces (infile);
-       ungetc (c, infile);
-       if (c == ')')
-         {
-           XSTR (return_rtx, i) = 0;
-           break;
-         }
-
       case 'T':
       case 's':
        {
          char *stringbuf;
+         int star_if_braced;
+
+         c = read_skip_spaces (infile);
+         ungetc (c, infile);
+         if (c == ')')
+           {
+             /* 'S' fields are optional and should be NULL if no string
+                was given.  Also allow normal 's' and 'T' strings to be
+                omitted, treating them in the same way as empty strings.  */
+             XSTR (return_rtx, i) = (format_ptr[-1] == 'S' ? NULL : "");
+             break;
+           }
 
          /* The output template slot of a DEFINE_INSN,
             DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
             gets a star inserted as its first character, if it is
             written with a brace block instead of a string constant.  */
-         int star_if_braced = (format_ptr[-1] == 'T');
+         star_if_braced = (format_ptr[-1] == 'T');
 
          stringbuf = read_string (&rtl_obstack, infile, star_if_braced);