OSDN Git Service

fix compile time warnings about unused epilogue instructions
[pf3gnuchains/gcc-fork.git] / gcc / cpplib.c
index 80f02de..90f6c80 100644 (file)
@@ -25,8 +25,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 #include "cpphash.h"
 #include "intl.h"
 
-#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
-#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)
+#define SKIP_WHITE_SPACE(p) do { while (is_hspace(*p)) p++; } while (0)
 
 #define PEEKN(N) (CPP_BUFFER (pfile)->rlimit - CPP_BUFFER (pfile)->cur >= (N) ? CPP_BUFFER (pfile)->cur[N] : EOF)
 #define FORWARD(N) CPP_FORWARD (CPP_BUFFER (pfile), (N))
@@ -49,6 +48,8 @@ static void skip_if_group             PROTO ((cpp_reader *));
 static void parse_name                 PARAMS ((cpp_reader *, int));
 static void parse_string               PARAMS ((cpp_reader *, int));
 static int parse_assertion             PARAMS ((cpp_reader *));
+static const char *if_directive_name   PARAMS ((cpp_reader *,
+                                                struct if_stack *));
 
 /* External declarations.  */
 
@@ -409,7 +410,7 @@ cpp_skip_hspace (pfile)
       c = GETC();
       if (c == EOF)
        return;
-      else if (is_hor_space[c])
+      else if (is_hspace(c))
        {
          if ((c == '\f' || c == '\v') && CPP_PEDANTIC (pfile))
            cpp_pedwarn (pfile, "%s in preprocessing directive",
@@ -526,11 +527,18 @@ handle_directive (pfile)
   cpp_skip_hspace (pfile);
 
   c = PEEKC ();
+  /* # followed by a number is equivalent to #line.  Do not recognize
+     this form in assembly language source files.  Complain about this
+     form if we're being pedantic, but not if this is regurgitated
+     input (preprocessed or fed back in by the C++ frontend).  */
   if (c >= '0' && c <= '9')
     {
-      /* Handle # followed by a line number.  Complain about using that
-         form if we're being pedantic, but not if this is regurgitated
-         input (preprocessed or fed back in by the C++ frontend).  */
+      if (CPP_OPTIONS (pfile)->lang_asm)
+       {
+         skip_rest_of_line (pfile);
+         return 1;
+       }
+
       if (CPP_PEDANTIC (pfile)
          && ! CPP_PREPROCESSED (pfile)
          && ! CPP_BUFFER (pfile)->manual_pop)
@@ -539,6 +547,11 @@ handle_directive (pfile)
       return 1;
     }
 
+  /* If we are rescanning preprocessed input, don't obey any directives
+     other than # nnn.  */
+  if (CPP_PREPROCESSED (pfile))
+    return 0;
+
   /* Now find the directive name.  */
   CPP_PUTC (pfile, '#');
   parse_name (pfile, GETC());
@@ -594,36 +607,29 @@ pass_thru_directive (buf, len, pfile, keyword)
   CPP_PUTS_Q (pfile, buf, len);
 }
 
-/* Check a purported macro name SYMNAME, and yield its length.
-   ASSERTION is nonzero if this is really for an assertion name.  */
+/* Check a purported macro name SYMNAME, and yield its length.  */
 
 int
-check_macro_name (pfile, symname, assertion)
+check_macro_name (pfile, symname)
      cpp_reader *pfile;
      const U_CHAR *symname;
-     int assertion;
 {
   const U_CHAR *p;
   int sym_length;
 
-  for (p = symname; is_idchar[*p]; p++)
+  for (p = symname; is_idchar(*p); p++)
     ;
   sym_length = p - symname;
   if (sym_length == 0
       || (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
-    cpp_error (pfile,
-              assertion ? "invalid assertion name" : "invalid macro name");
-  else if (!is_idstart[*symname]
+    cpp_error (pfile, "invalid macro name");
+  else if (!is_idstart(*symname)
           || (! strncmp (symname, "defined", 7) && sym_length == 7)) {
     U_CHAR *msg;                       /* what pain...  */
     msg = (U_CHAR *) alloca (sym_length + 1);
     bcopy (symname, msg, sym_length);
     msg[sym_length] = 0;
-    cpp_error (pfile,
-              (assertion
-               ? "invalid assertion name `%s'"
-               : "invalid macro name `%s'"),
-              msg);
+    cpp_error (pfile, "invalid macro name `%s'", msg);
   }
   return sym_length;
 }
@@ -1352,7 +1358,7 @@ do_line (pfile, keyword)
       
       if (strcmp (fname, ip->nominal_fname))
        {
-         char *newname, *oldname;
+         const char *newname, *oldname;
          if (!strcmp (fname, ip->fname))
            newname = ip->fname;
          else if (ip->last_nominal_fname
@@ -1368,7 +1374,7 @@ do_line (pfile, keyword)
              && ip->last_nominal_fname != oldname
              && ip->last_nominal_fname != newname
              && ip->last_nominal_fname != ip->fname)
-           free (ip->last_nominal_fname);
+           free ((void *) ip->last_nominal_fname);
 
          if (newname == ip->fname)
            ip->last_nominal_fname = NULL;
@@ -1413,7 +1419,7 @@ do_undef (pfile, keyword)
 
   cpp_skip_hspace (pfile);
   c = GETC();
-  if (! is_idstart[c])
+  if (! is_idstart(c))
   {
       cpp_error (pfile, "token after #undef is not an identifier");
       skip_rest_of_line (pfile);
@@ -1438,7 +1444,7 @@ do_undef (pfile, keyword)
 
   CPP_SET_WRITTEN (pfile, here);
 
-  sym_length = check_macro_name (pfile, buf, 0);
+  sym_length = check_macro_name (pfile, buf);
 
   while ((hp = cpp_lookup (pfile, name, sym_length, -1)) != NULL)
     {
@@ -1641,10 +1647,10 @@ do_pragma (pfile, keyword)
        {
          U_CHAR *end = syms;
          
-         while (is_idchar[*end])
+         while (is_idchar(*end))
            end++;
 
-         if (!is_hor_space[*end] && *end != '\0')
+         if (!is_hspace(*end) && *end != '\0')
            {
              cpp_error (pfile, "invalid #pragma poison directive");
              return 1;
@@ -1922,7 +1928,7 @@ do_xifdef (pfile, keyword)
       else {
        U_CHAR *cp = buf;
        fprintf (pcp_outfile, "#undef ");
-       while (is_idchar[*cp]) /* Ick! */
+       while (is_idchar(*cp)) /* Ick! */
          fputc (*cp++, pcp_outfile);
        putc ('\n', pcp_outfile);
       }
@@ -2394,6 +2400,12 @@ cpp_get_token (pfile)
 
          if (!pfile->only_seen_white)
            goto randomchar;
+         /* -traditional directives are recognized only with the # in
+            column 1.
+            XXX Layering violation.  */
+         if (CPP_TRADITIONAL (pfile)
+             && CPP_BUFFER (pfile)->cur - CPP_BUFFER (pfile)->line_base != 1)
+           goto randomchar;
          if (handle_directive (pfile))
            return CPP_DIRECTIVE;
          pfile->only_seen_white = 0;
@@ -2571,7 +2583,7 @@ cpp_get_token (pfile)
              c = PEEKC ();
              if (c == EOF)
                break;
-             if (!is_idchar[c] && c != '.'
+             if (!is_idchar(c) && c != '.'
                  && ((c2 != 'e' && c2 != 'E'
                       && ((c2 != 'p' && c2 != 'P') || CPP_C89 (pfile)))
                      || (c != '+' && c != '-')))
@@ -2596,7 +2608,7 @@ cpp_get_token (pfile)
                  c = GETC();
                  if (c == EOF)
                    goto chill_number_eof;
-                 if (!is_idchar[c])
+                 if (!is_idchar(c))
                    break;
                  CPP_PUTC (pfile, c);
                }
@@ -2718,7 +2730,7 @@ cpp_get_token (pfile)
            {
              CPP_PUTC (pfile, c);
              c = PEEKC ();
-             if (c == EOF || !is_hor_space[c])
+             if (c == EOF || !is_hspace(c))
                break;
              FORWARD(1);
            }
@@ -2814,7 +2826,7 @@ parse_name (pfile, c)
 {
   for (;;)
   {
-      if (! is_idchar[c])
+      if (! is_idchar(c))
       {
          FORWARD (-1);
          break;
@@ -2878,9 +2890,17 @@ parse_string (pfile, c)
        case '\n':
          CPP_BUMP_LINE (pfile);
          pfile->lineno++;
+
+         /* In Fortran and assembly language, silently terminate
+            strings of either variety at end of line.  This is a
+            kludge around not knowing where comments are in these
+            languages.  */
+         if (CPP_OPTIONS (pfile)->lang_fortran
+             || CPP_OPTIONS (pfile)->lang_asm)
+           return;
          /* Character constants may not extend over multiple lines.
-            In ANSI, neither may strings.  We accept multiline strings
-            as an extension.  */
+            In Standard C, neither may strings.  We accept multiline
+            strings as an extension.  */
          if (c == '\'')
            {
              cpp_error_with_line (pfile, start_line, start_column,
@@ -2888,10 +2908,8 @@ parse_string (pfile, c)
              return;
            }
          if (CPP_PEDANTIC (pfile) && pfile->multiline_string_line == 0)
-           {
-             cpp_pedwarn_with_line (pfile, start_line, start_column,
-                                    "string constant runs past end of line");
-           }
+           cpp_pedwarn_with_line (pfile, start_line, start_column,
+                                  "string constant runs past end of line");
          if (pfile->multiline_string_line == 0)
            pfile->multiline_string_line = start_line;
          break;
@@ -2937,7 +2955,7 @@ parse_assertion (pfile)
   int c, dropwhite;
   cpp_skip_hspace (pfile);
   c = PEEKC();
-  if (! is_idstart[c])
+  if (! is_idstart(c))
     {
       cpp_error (pfile, "assertion predicate is not an identifier");
       return 0;
@@ -2949,7 +2967,7 @@ parse_assertion (pfile)
   c = PEEKC();
   if (c != '(')
     {
-      if (is_hor_space[c] || c == '\r')
+      if (is_hspace(c) || c == '\r')
        cpp_skip_hspace (pfile);
       c = PEEKC();
     }
@@ -2961,7 +2979,7 @@ parse_assertion (pfile)
   dropwhite = 1;
   while ((c = GETC()) != ')')
     {
-      if (is_hor_space[c])
+      if (is_space(c))
        {
          if (! dropwhite)
            {