OSDN Git Service

PR fortran/13930
[pf3gnuchains/gcc-fork.git] / gcc / f / lex.c
index cee6cab..9a38ad5 100644 (file)
@@ -1,5 +1,6 @@
 /* Implementation of Fortran lexer
-   Copyright (C) 1995-1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 2001, 2002, 2003
+   Free Software Foundation, Inc.
    Contributed by James Craig Burley.
 
 This file is part of GNU Fortran.
@@ -26,21 +27,12 @@ the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "lex.h"
 #include "malloc.h"
 #include "src.h"
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-#include "flags.j"
-#include "input.j"
-#include "toplev.j"
-#include "tree.j"
-#include "output.j"  /* Must follow tree.j so TREE_CODE is defined! */
-#include "ggc.j"
-#endif
-
-#ifdef DWARF_DEBUGGING_INFO
-void dwarfout_resume_previous_source_file (register unsigned);
-void dwarfout_start_new_source_file (register char *);
-void dwarfout_define (register unsigned, register char *);
-void dwarfout_undef (register unsigned, register char *);
-#endif DWARF_DEBUGGING_INFO
+#include "debug.h"
+#include "flags.h"
+#include "input.h"
+#include "toplev.h"
+#include "output.h"
+#include "ggc.h"
 
 static void ffelex_append_to_token_ (char c);
 static int ffelex_backslash_ (int c, ffewhereColumnNumber col);
@@ -52,10 +44,8 @@ static void ffelex_bad_2_ (ffebad errnum, ffewhereLineNumber ln0,
 static void ffelex_bad_here_ (int num, ffewhereLineNumber ln0,
                              ffewhereColumnNumber cn0);
 static void ffelex_finish_statement_ (void);
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static int ffelex_get_directive_line_ (char **text, FILE *finput);
 static int ffelex_hash_ (FILE *f);
-#endif
 static ffewhereColumnNumber ffelex_image_char_ (int c,
                                                ffewhereColumnNumber col);
 static void ffelex_include_ (void);
@@ -103,7 +93,7 @@ static ffelexType ffelex_first_char_[256];
 
 /* The wf argument of the most recent active ffelex_file_(fixed,free)
    function.  */
-static ffewhereFile ffelex_current_wf_;
+static GTY (()) ffewhereFile ffelex_current_wf_;
 
 /* TRUE if an INCLUDE statement can be processed (ffelex_set_include
    can be called).  */
@@ -116,7 +106,7 @@ static bool ffelex_set_include_;
 /* Information on the pending INCLUDE file.  */
 static FILE *ffelex_include_file_;
 static bool ffelex_include_free_form_;
-static ffewhereFile ffelex_include_wherefile_;
+static GTY(()) ffewhereFile ffelex_include_wherefile_;
 
 /* Current master line count.  */
 static ffewhereLineNumber ffelex_linecount_current_;
@@ -229,11 +219,6 @@ ffelex_append_to_token_ (char c)
       ffelex_token_->size <<= 1;
       assert (ffelex_token_->length < ffelex_token_->size);
     }
-#ifdef MAP_CHARACTER
-Sorry, MAP_CHARACTER is not going to work as expected in GNU Fortran,
-please contact fortran@gnu.org if you wish to fund work to
-port g77 to non-ASCII machines.
-#endif
   ffelex_token_->text[ffelex_token_->length++] = c;
 }
 
@@ -256,8 +241,6 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
      hollerith constants.  */
 
 #define wide_flag 0
-#define warn_traditional 0
-#define flag_traditional 0
 
   switch (state)
     {
@@ -278,17 +261,6 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
       switch (c)
        {
        case 'x':
-         if (warn_traditional)
-           {
-             ffebad_start_msg_lex ("The meaning of `\\x' (at %0) varies with -traditional",
-                                   FFEBAD_severityWARNING);
-             ffelex_bad_here_ (0, line, column);
-             ffebad_finish ();
-           }
-
-         if (flag_traditional)
-           return c;
-
          code = 0;
          count = 0;
          nonnull = 0;
@@ -328,23 +300,9 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
          return TARGET_BS;
 
        case 'a':
-         if (warn_traditional)
-           {
-             ffebad_start_msg_lex ("The meaning of `\\a' (at %0) varies with -traditional",
-                                   FFEBAD_severityWARNING);
-             ffelex_bad_here_ (0, line, column);
-             ffebad_finish ();
-           }
-
-         if (flag_traditional)
-           return c;
          return TARGET_BELL;
 
        case 'v':
-#if 0 /* Vertical tab is present in common usage compilers.  */
-         if (flag_traditional)
-           return c;
-#endif
          return TARGET_VT;
 
        case 'e':
@@ -359,7 +317,8 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
 
              m[0] = c;
              m[1] = '\0';
-             ffebad_start_msg_lex ("Non-ANSI-C-standard escape sequence `\\%A' at %0",
+             /* xgettext:no-c-format */
+             ffebad_start_msg_lex ("Non-ISO-C-standard escape sequence `\\%A' at %0",
                                    FFEBAD_severityPEDANTIC);
              ffelex_bad_here_ (0, line, column);
              ffebad_string (m);
@@ -377,6 +336,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
 
              m[0] = c;
              m[1] = '\0';
+             /* xgettext:no-c-format */
              ffebad_start_msg_lex ("Unknown escape sequence `\\%A' at %0",
                                    FFEBAD_severityPEDANTIC);
              ffelex_bad_here_ (0, line, column);
@@ -385,6 +345,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
            }
          else if (c == EOF)
            {
+             /* xgettext:no-c-format */
              ffebad_start_msg_lex ("Unterminated escape sequence `\\' at %0",
                                    FFEBAD_severityPEDANTIC);
              ffelex_bad_here_ (0, line, column);
@@ -395,6 +356,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
              char m[20];
 
              sprintf (&m[0], "%x", c);
+             /* xgettext:no-c-format */
              ffebad_start_msg_lex ("Unknown escape sequence `\\' followed by char code 0x%A at %0",
                                    FFEBAD_severityPEDANTIC);
              ffelex_bad_here_ (0, line, column);
@@ -405,17 +367,9 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
       return c;
 
     case 2:
-      if ((c >= 'a' && c <= 'f')
-         || (c >= 'A' && c <= 'F')
-         || (c >= '0' && c <= '9'))
+      if (ISXDIGIT (c))
        {
-         code *= 16;
-         if (c >= 'a' && c <= 'f')
-           code += c - 'a' + 10;
-         if (c >= 'A' && c <= 'F')
-           code += c - 'A' + 10;
-         if (c >= '0' && c <= '9')
-           code += c - '0';
+         code = (code * 16) + hex_value (c);
          if (code != 0 || count != 0)
            {
              if (count == 0)
@@ -430,6 +384,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
 
       if (! nonnull)
        {
+         /* xgettext:no-c-format */
          ffebad_start_msg_lex ("\\x used at %0 with no following hex digits",
                                FFEBAD_severityFATAL);
          ffelex_bad_here_ (0, line, column);
@@ -443,6 +398,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
                   && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
                       <= (int) firstdig)))
        {
+         /* xgettext:no-c-format */
          ffebad_start_msg_lex ("Hex escape at %0 out of range",
                                FFEBAD_severityPEDANTIC);
          ffelex_bad_here_ (0, line, column);
@@ -476,6 +432,7 @@ ffelex_backslash_ (int c, ffewhereColumnNumber col)
       && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
       && code >= (1 << TYPE_PRECISION (char_type_node)))
     {
+      /* xgettext:no-c-format */
       ffebad_start_msg_lex ("Escape sequence at %0 out of range for character",
                            FFEBAD_severityFATAL);
       ffelex_bad_here_ (0, line, column);
@@ -568,7 +525,6 @@ ffelex_bad_here_ (int n, ffewhereLineNumber ln0,
   ffewhere_column_kill (wc0);
 }
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static int
 ffelex_getc_ (FILE *finput)
 {
@@ -585,8 +541,6 @@ ffelex_getc_ (FILE *finput)
   return getc (finput);
 }
 
-#endif
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static int
 ffelex_cfebackslash_ (int *use_d, int *d, FILE *finput)
 {
@@ -601,33 +555,19 @@ ffelex_cfebackslash_ (int *use_d, int *d, FILE *finput)
   switch (c)
     {
     case 'x':
-      if (warn_traditional)
-       warning ("the meaning of `\\x' varies with -traditional");
-
-      if (flag_traditional)
-       return c;
-
       code = 0;
       count = 0;
       nonnull = 0;
       while (1)
        {
          c = getc (finput);
-         if (!(c >= 'a' && c <= 'f')
-             && !(c >= 'A' && c <= 'F')
-             && !(c >= '0' && c <= '9'))
+         if (! ISXDIGIT (c))
            {
              *use_d = 1;
              *d = c;
              break;
            }
-         code *= 16;
-         if (c >= 'a' && c <= 'f')
-           code += c - 'a' + 10;
-         if (c >= 'A' && c <= 'F')
-           code += c - 'A' + 10;
-         if (c >= '0' && c <= '9')
-           code += c - '0';
+         code = (code * 16) + hex_value (c);
          if (code != 0 || count != 0)
            {
              if (count == 0)
@@ -692,18 +632,9 @@ ffelex_cfebackslash_ (int *use_d, int *d, FILE *finput)
       return TARGET_BS;
 
     case 'a':
-      if (warn_traditional)
-       warning ("the meaning of `\\a' varies with -traditional");
-
-      if (flag_traditional)
-       return c;
       return TARGET_BELL;
 
     case 'v':
-#if 0 /* Vertical tab is present in common usage compilers.  */
-      if (flag_traditional)
-       return c;
-#endif
       return TARGET_VT;
 
     case 'e':
@@ -722,7 +653,7 @@ ffelex_cfebackslash_ (int *use_d, int *d, FILE *finput)
       /* `\%' is used to prevent SCCS from getting confused.  */
     case '%':
       if (pedantic)
-       pedwarn ("non-ANSI escape sequence `\\%c'", c);
+       pedwarn ("non-ISO escape sequence `\\%c'", c);
       return c;
     }
   if (c >= 040 && c < 0177)
@@ -732,10 +663,8 @@ ffelex_cfebackslash_ (int *use_d, int *d, FILE *finput)
   return c;
 }
 
-#endif
 /* A miniature version of the C front-end lexer.  */
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static int
 ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
 {
@@ -765,7 +694,13 @@ ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
              register unsigned bytes_used = (p - q);
 
              buffer_length *= 2;
-             q = (char *)xrealloc (q, buffer_length);
+             if (q == &buff[0])
+               {
+                 q = xmalloc (buffer_length);
+                 memcpy (q, buff, bytes_used);
+               }
+             else
+               q = xrealloc (q, buffer_length);
              p = &q[bytes_used];
              r = &q[buffer_length];
            }
@@ -792,7 +727,7 @@ ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
        {
          bool done = FALSE;
          int use_d = 0;
-         int d;
+         int d = 0;
 
          switch (c)
            {
@@ -807,7 +742,7 @@ ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
 
            case EOF:
            case '\n':
-             fatal ("Badly formed directive -- no closing quote");
+             error ("badly formed directive -- no closing quote");
              done = TRUE;
              break;
 
@@ -825,7 +760,13 @@ ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
                  register unsigned bytes_used = (p - q);
 
                  buffer_length = bytes_used * 2;
-                 q = (char *)xrealloc (q, buffer_length);
+                 if (q == &buff[0])
+                   {
+                     q = xmalloc (buffer_length);
+                     memcpy (q, buff, bytes_used);
+                   }
+                 else
+                   q = xrealloc (q, buffer_length);
                  p = &q[bytes_used];
                  r = &q[buffer_length];
                }
@@ -852,11 +793,9 @@ ffelex_cfelex_ (ffelexToken *xtoken, FILE *finput, int c)
   *xtoken = token;
   return c;
 }
-#endif
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static void
-ffelex_file_pop_ (char *input_filename)
+ffelex_file_pop_ (const char *filename)
 {
   if (input_file_stack->next)
     {
@@ -864,11 +803,7 @@ ffelex_file_pop_ (char *input_filename)
       input_file_stack = p->next;
       free (p);
       input_file_stack_tick++;
-#ifdef DWARF_DEBUGGING_INFO
-      if (debug_info_level == DINFO_LEVEL_VERBOSE
-         && write_symbols == DWARF_DEBUG)
-       dwarfout_resume_previous_source_file (input_file_stack->line);
-#endif /* DWARF_DEBUGGING_INFO */
+      (*debug_hooks->end_source_file) (input_file_stack->location.line);
     }
   else
     error ("#-lines for entering and leaving files don't match");
@@ -876,34 +811,27 @@ ffelex_file_pop_ (char *input_filename)
   /* Now that we've pushed or popped the input stack,
      update the name in the top element.  */
   if (input_file_stack)
-    input_file_stack->name = input_filename;
+    input_file_stack->location.file = filename;
 }
 
-#endif
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static void
-ffelex_file_push_ (int old_lineno, char *input_filename)
+ffelex_file_push_ (int old_lineno, const char *filename)
 {
-  struct file_stack *p
-    = (struct file_stack *) xmalloc (sizeof (struct file_stack));
+  struct file_stack *p = xmalloc (sizeof (struct file_stack));
 
-  input_file_stack->line = old_lineno;
+  input_file_stack->location.line = old_lineno;
   p->next = input_file_stack;
-  p->name = input_filename;
+  p->location.file = filename;
   input_file_stack = p;
   input_file_stack_tick++;
-#ifdef DWARF_DEBUGGING_INFO
-  if (debug_info_level == DINFO_LEVEL_VERBOSE
-      && write_symbols == DWARF_DEBUG)
-    dwarfout_start_new_source_file (input_filename);
-#endif /* DWARF_DEBUGGING_INFO */
+
+  (*debug_hooks->start_source_file) (0, filename);
 
   /* Now that we've pushed or popped the input stack,
      update the name in the top element.  */
   if (input_file_stack)
-    input_file_stack->name = input_filename;
+    input_file_stack->location.file = filename;
 }
-#endif
 
 /* Prepare to finish a statement-in-progress by sending the current
    token, if any, then setting up EOS as the current token with the
@@ -912,7 +840,7 @@ ffelex_file_push_ (int old_lineno, char *input_filename)
    typical fixed-form cases.  */
 
 static void
-ffelex_prepare_eos_ ()
+ffelex_prepare_eos_ (void)
 {
   if (ffelex_token_->type != FFELEX_typeNONE)
     {
@@ -961,7 +889,7 @@ ffelex_prepare_eos_ ()
 }
 
 static void
-ffelex_finish_statement_ ()
+ffelex_finish_statement_ (void)
 {
   if ((ffelex_number_of_tokens_ == 0)
       && (ffelex_token_->type == FFELEX_typeNONE))
@@ -992,9 +920,12 @@ ffelex_finish_statement_ ()
     }
 }
 
-/* Copied from gcc/c-common.c get_directive_line.  */
+/* Read a preprocessor directive line from file FINPUT.  This function
+   returns either '\n' or EOF to indicate success or failure respectively.
+   Upon return, TEXT points to the contents of the line, which is stripped
+   of initial whitespace.  The buffer pointed to by TEXT should not be
+   free'd and is overwritten by subsequent calls to this function.  */
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 static int
 ffelex_get_directive_line_ (char **text, FILE *finput)
 {
@@ -1007,7 +938,7 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
 
   if (buffer_length == 0)
     {
-      directive_buffer = (char *)xmalloc (128);
+      directive_buffer = xmalloc (128);
       buffer_length = 128;
     }
 
@@ -1023,8 +954,7 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
          register unsigned bytes_used = (p - directive_buffer);
 
          buffer_length *= 2;
-         directive_buffer
-           = (char *)xrealloc (directive_buffer, buffer_length);
+         directive_buffer = xrealloc (directive_buffer, buffer_length);
          p = &directive_buffer[bytes_used];
          buffer_limit = &directive_buffer[buffer_length];
        }
@@ -1040,7 +970,7 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
          || c == EOF)
        {
          if (looking_for != 0)
-           fatal ("Bad directive -- missing close-quote");
+           error ("bad directive -- missing close-quote");
 
          *p++ = '\0';
          *text = directive_buffer;
@@ -1066,7 +996,6 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
       char_escaped = (c == '\\' && ! char_escaped);
     }
 }
-#endif
 
 /* Handle # directives that make it through (or are generated by) the
    preprocessor.  As much as reasonably possible, emulate the behavior
@@ -1077,24 +1006,6 @@ ffelex_get_directive_line_ (char **text, FILE *finput)
 
    Returns the next character unhandled, which is always newline or EOF.  */
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-
-#if defined HANDLE_PRAGMA
-/* Local versions of these macros, that can be passed as function pointers.  */
-static int
-pragma_getc ()
-{
-  return getc (finput);
-}
-
-static void
-pragma_ungetc (arg)
-     int arg;
-{
-  ungetc (arg, finput);
-}
-#endif /* HANDLE_PRAGMA */
-
 static int
 ffelex_hash_ (FILE *finput)
 {
@@ -1111,7 +1022,7 @@ ffelex_hash_ (FILE *finput)
      it and ignore it; otherwise, ignore the line, with an error
      if the word isn't `pragma', `ident', `define', or `undef'.  */
 
-  if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+  if (ISALPHA(c))
     {
       if (c == 'p')
        {
@@ -1123,46 +1034,9 @@ ffelex_hash_ (FILE *finput)
              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'
                  || c == EOF))
            {
-#if 0  /* g77 doesn't handle pragmas, so ignores them FOR NOW. */
-             static char buffer [128];
-             char * buff = buffer;
-
-             /* Read the pragma name into a buffer.
-                ISSPACE() may evaluate its argument more than once!  */
-             while (((c = getc (finput)), ISSPACE(c)))
-               continue;
-             
-             do
-               {
-                 * buff ++ = c;
-                 c = getc (finput);
-               }
-             while (c != EOF && ! ISSPACE (c) && c != '\n'
-                    && buff < buffer + 128);
-
-             pragma_ungetc (c);
-               
-             * -- buff = 0;
-#ifdef HANDLE_PRAGMA
-             if (HANDLE_PRAGMA (pragma_getc, pragma_ungetc, buffer))
-               goto skipline;
-#endif /* HANDLE_PRAGMA */
-#ifdef HANDLE_GENERIC_PRAGMAS
-             if (handle_generic_pragma (buffer))
-               goto skipline;
-#endif /* !HANDLE_GENERIC_PRAGMAS */
-
-             /* Issue a warning message if we have been asked to do so.
-                Ignoring unknown pragmas in system header file unless
-                an explcit -Wunknown-pragmas has been given. */
-             if (warn_unknown_pragmas > 1
-                 || (warn_unknown_pragmas && ! in_system_header))
-               warning ("ignoring pragma: %s", token_buffer);
-#endif /* 0 */
              goto skipline;
            }
        }
-
       else if (c == 'd')
        {
          if (getc (finput) == 'e'
@@ -1177,11 +1051,8 @@ ffelex_hash_ (FILE *finput)
 
              c = ffelex_get_directive_line_ (&text, finput);
 
-#ifdef DWARF_DEBUGGING_INFO
-             if ((debug_info_level == DINFO_LEVEL_VERBOSE)
-                 && (write_symbols == DWARF_DEBUG))
-               dwarfout_define (lineno, text);
-#endif /* DWARF_DEBUGGING_INFO */
+             if (debug_info_level == DINFO_LEVEL_VERBOSE)
+               (*debug_hooks->define) (input_line, text);
 
              goto skipline;
            }
@@ -1199,11 +1070,8 @@ ffelex_hash_ (FILE *finput)
 
              c = ffelex_get_directive_line_ (&text, finput);
 
-#ifdef DWARF_DEBUGGING_INFO
-             if ((debug_info_level == DINFO_LEVEL_VERBOSE)
-                 && (write_symbols == DWARF_DEBUG))
-               dwarfout_undef (lineno, text);
-#endif /* DWARF_DEBUGGING_INFO */
+             if (debug_info_level == DINFO_LEVEL_VERBOSE)
+               (*debug_hooks->undef) (input_line, text);
 
              goto skipline;
            }
@@ -1224,7 +1092,7 @@ ffelex_hash_ (FILE *finput)
              && getc (finput) == 't'
              && ((c = getc (finput)) == ' ' || c == '\t'))
            {
-             /* #ident.  The pedantic warning is now in cccp.c.  */
+             /* #ident.  The pedantic warning is now in cpp.  */
 
              /* Here we have just seen `#ident '.
                 A string constant should follow.  */
@@ -1281,8 +1149,7 @@ ffelex_hash_ (FILE *finput)
   if ((token != NULL)
       && (ffelex_token_type (token) == FFELEX_typeNUMBER))
     {
-      int old_lineno = lineno;
-      char *old_input_filename = input_filename;
+      location_t old_loc = input_location;
       ffewhereFile wf;
 
       /* subtract one, because it is the following line that
@@ -1295,7 +1162,7 @@ ffelex_hash_ (FILE *finput)
       if (c == '\n' || c == EOF)
        {
          /* No more: store the line number and check following line.  */
-         lineno = l;
+         input_line = l;
          if (!ffelex_kludge_flag_)
            {
              ffewhere_file_set (NULL, TRUE, (ffewhereLineNumber) l);
@@ -1318,10 +1185,10 @@ ffelex_hash_ (FILE *finput)
          goto skipline;
        }
 
-      lineno = l;
+      input_line = l;
 
       if (ffelex_kludge_flag_)
-       input_filename = ggc_alloc_string (ffelex_token_text (token), -1);
+       input_filename = ggc_strdup (ffelex_token_text (token));
       else
        {
          wf = ffewhere_file_new (ffelex_token_text (token),
@@ -1348,7 +1215,7 @@ ffelex_hash_ (FILE *finput)
            {
              /* Update the name in the top element of input_file_stack.  */
              if (input_file_stack)
-               input_file_stack->name = input_filename;
+               input_file_stack->location.file = input_filename;
 
              if (token != NULL)
                ffelex_token_kill (token);
@@ -1368,15 +1235,15 @@ ffelex_hash_ (FILE *finput)
 
          if (ffelex_kludge_flag_)
            {
-             lineno = 1;
-             input_filename = old_input_filename;
-             fatal ("Use `#line ...' instead of `# ...' in first line");
+             input_line = 1;
+             input_filename = old_loc.file;
+             error ("use `#line ...' instead of `# ...' in first line");
            }
 
          if (num == 1)
            {
              /* Pushing to a new file.  */
-             ffelex_file_push_ (old_lineno, input_filename);
+             ffelex_file_push_ (old_loc.line, input_filename);
            }
          else if (num == 2)
            {
@@ -1412,9 +1279,15 @@ ffelex_hash_ (FILE *finput)
           || (c != '\n' && c != EOF))
          && ffelex_kludge_flag_)
        {
-         lineno = 1;
-         input_filename = old_input_filename;
-         fatal ("Use `#line ...' instead of `# ...' in first line");
+         input_line = 1;
+         input_filename = old_loc.file;
+         error ("use `#line ...' instead of `# ...' in first line");
+       }
+      if (c == '\n' || c == EOF)
+       {
+         if (token != NULL && !ffelex_kludge_flag_)
+           ffelex_token_kill (token);
+         return c;
        }
     }
   else
@@ -1428,7 +1301,6 @@ ffelex_hash_ (FILE *finput)
     ;
   return c;
 }
-#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
 
 /* "Image" a character onto the card image, return incremented column number.
 
@@ -1511,6 +1383,7 @@ ffelex_image_char_ (int c, ffewhereColumnNumber column)
          ffelex_bad_line_ = TRUE;
          strcpy (&ffelex_card_image_[column], "[\\0]");
          ffelex_card_length_ = column + 4;
+         /* xgettext:no-c-format */
          ffebad_start_msg_lex ("Null character at %0 -- line ignored",
                                FFEBAD_severityFATAL);
          ffelex_bad_here_ (0, ffelex_linecount_current_, column + 1);
@@ -1534,7 +1407,7 @@ ffelex_image_char_ (int c, ffewhereColumnNumber column)
 }
 
 static void
-ffelex_include_ ()
+ffelex_include_ (void)
 {
   ffewhereFile include_wherefile = ffelex_include_wherefile_;
   FILE *include_file = ffelex_include_file_;
@@ -1552,10 +1425,7 @@ ffelex_include_ ()
   ffewhereLineNumber linecount_current = ffelex_linecount_current_;
   ffewhereLineNumber linecount_offset
     = ffewhere_line_filelinenum (current_wl);
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  int old_lineno = lineno;
-  char *old_input_filename = input_filename;
-#endif
+  location_t old_loc = input_location;
 
   if (card_length != 0)
     {
@@ -1573,18 +1443,14 @@ ffelex_include_ ()
 
   ffewhere_file_set (include_wherefile, TRUE, 0);
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  ffelex_file_push_ (old_lineno, ffewhere_file_name (include_wherefile));
-#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
+  ffelex_file_push_ (old_loc.line, ffewhere_file_name (include_wherefile));
 
   if (ffelex_include_free_form_)
     ffelex_file_free (include_wherefile, include_file);
   else
     ffelex_file_fixed (include_wherefile, include_file);
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
   ffelex_file_pop_ (ffewhere_file_name (current_wf));
-#endif /* FFECOM_targetCURRENT == FFECOM_targetGCC */
 
   ffewhere_file_set (current_wf, TRUE, linecount_offset);
 
@@ -1592,18 +1458,12 @@ ffelex_include_ ()
 
   if (card_length != 0)
     {
-#ifdef REDUCE_CARD_SIZE_AFTER_BIGGY    /* Define if occasional large lines. */
-#error "need to handle possible reduction of card size here!!"
-#endif
       assert (ffelex_card_size_ >= card_length);       /* It shrunk?? */
       memcpy (ffelex_card_image_, card_image, card_length);
     }
   ffelex_card_image_[card_length] = '\0';
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  input_filename = old_input_filename;
-  lineno = old_lineno;
-#endif
+  input_location = old_loc;
   ffelex_linecount_current_ = linecount_current;
   ffelex_current_wf_ = current_wf;
   ffelex_final_nontab_column_ = final_nontab_column;
@@ -1657,17 +1517,15 @@ ffelex_is_free_nonc_ctx_contin_ (ffewhereColumnNumber col)
 }
 
 static void
-ffelex_next_line_ ()
+ffelex_next_line_ (void)
 {
   ffelex_linecount_current_ = ffelex_linecount_next_;
   ++ffelex_linecount_next_;
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  ++lineno;
-#endif
+  ++input_line;
 }
 
 static void
-ffelex_send_token_ ()
+ffelex_send_token_ (void)
 {
   ++ffelex_number_of_tokens_;
 
@@ -1741,14 +1599,13 @@ ffelex_swallow_tokens_ (ffelexToken t)
 }
 
 static ffelexToken
-ffelex_token_new_ ()
+ffelex_token_new_ (void)
 {
   ffelexToken t;
 
   ++ffelex_total_tokens_;
 
-  t = (ffelexToken) malloc_new_ks (malloc_pool_image (),
-                                  "FFELEX token", sizeof (*t));
+  t = malloc_new_ks (malloc_pool_image (), "FFELEX token", sizeof (*t));
   t->id_ = ffelex_token_nextid_++;
   return t;
 }
@@ -1756,7 +1613,7 @@ ffelex_token_new_ ()
 static const char *
 ffelex_type_string_ (ffelexType type)
 {
-  static const char *types[] = {
+  static const char *const types[] = {
     "FFELEX_typeNONE",
     "FFELEX_typeCOMMENT",
     "FFELEX_typeEOS",
@@ -1839,7 +1696,7 @@ ffelex_display_token (ffelexToken t)
    return FALSE.  */
 
 bool
-ffelex_expecting_character ()
+ffelex_expecting_character (void)
 {
   return (ffelex_raw_mode_ != 0);
 }
@@ -1879,10 +1736,8 @@ ffelex_file_fixed (ffewhereFile wf, FILE *f)
 
   assert (ffelex_handler_ != NULL);
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  lineno = 0;
+  input_line = 0;
   input_filename = ffewhere_file_name (wf);
-#endif
   ffelex_current_wf_ = wf;
   disallow_continuation_line = TRUE;
   ignore_disallowed_continuation = FALSE;
@@ -1893,22 +1748,6 @@ ffelex_file_fixed (ffewhereFile wf, FILE *f)
   ffelex_current_wc_ = ffewhere_column_unknown ();
   latest_char_in_file = '\n';
 
-  if (ffe_is_null_version ())
-    {
-      /* Just substitute a "program" directly here.  */
-
-      char line[] = "      call g77__fvers;call g77__ivers;call g77__uvers;end";
-      char *p;
-
-      column = 0;
-      for (p = &line[0]; *p != '\0'; ++p)
-       column = ffelex_image_char_ (*p, column);
-
-      c = EOF;
-
-      goto have_line;          /* :::::::::::::::::::: */
-    }
-
   goto first_line;             /* :::::::::::::::::::: */
 
   /* Come here to get a new line. */
@@ -1921,18 +1760,6 @@ ffelex_file_fixed (ffewhereFile wf, FILE *f)
 
  beginning_of_line_again:      /* :::::::::::::::::::: */
 
-#ifdef REDUCE_CARD_SIZE_AFTER_BIGGY    /* Define if occasional large lines. */
-  if (ffelex_card_size_ != FFELEX_columnINITIAL_SIZE_)
-    {
-      ffelex_card_image_
-       = malloc_resize_ks (malloc_pool_image (),
-                           ffelex_card_image_,
-                           FFELEX_columnINITIAL_SIZE_ + 9,
-                           ffelex_card_size_ + 9);
-      ffelex_card_size_ = FFELEX_columnINITIAL_SIZE_;
-    }
-#endif
-
  first_line:                   /* :::::::::::::::::::: */
 
   c = latest_char_in_file;
@@ -1971,10 +1798,8 @@ ffelex_file_fixed (ffewhereFile wf, FILE *f)
          while ((c != '\n') && (c != EOF))
            c = getc (f);
        }
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
       else if (lextype == FFELEX_typeHASH)
        c = ffelex_hash_ (f);
-#endif
       else if (lextype == FFELEX_typeSLASH)
        {
          /* SIDE-EFFECT ABOVE HAS HAPPENED. */
@@ -2057,8 +1882,6 @@ ffelex_file_fixed (ffewhereFile wf, FILE *f)
       column = ffelex_final_nontab_column_;
     }
 
- have_line:                    /* :::::::::::::::::::: */
-
   ffelex_card_image_[column] = '\0';
   ffelex_card_length_ = column;
 
@@ -3091,10 +2914,8 @@ ffelex_file_free (ffewhereFile wf, FILE *f)
 
   assert (ffelex_handler_ != NULL);
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-  lineno = 0;
+  input_line = 0;
   input_filename = ffewhere_file_name (wf);
-#endif
   ffelex_current_wf_ = wf;
   continuation_line = FALSE;
   ffelex_token_->type = FFELEX_typeNONE;
@@ -3132,14 +2953,7 @@ ffelex_file_free (ffewhereFile wf, FILE *f)
         || (c == '#'))
     {
       if (c == '#')
-       {
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
-         c = ffelex_hash_ (f);
-#else
-         /* Don't skip over # line after all.  */
-         break;
-#endif
-       }
+       c = ffelex_hash_ (f);
 
      comment_line:             /* :::::::::::::::::::: */
 
@@ -3982,17 +3796,16 @@ ffelex_file_free (ffewhereFile wf, FILE *f)
 
 /* See the code in com.c that calls this to understand why.  */
 
-#if FFECOM_targetCURRENT == FFECOM_targetGCC
 void
 ffelex_hash_kludge (FILE *finput)
 {
   /* If you change this constant string, you have to change whatever
      code might thus be affected by it in terms of having to use
      ffelex_getc_() instead of getc() in the lexers and _hash_.  */
-  static char match[] = "# 1 \"";
+  static const char match[] = "# 1 \"";
   static int kludge[ARRAY_SIZE (match) + 1];
   int c;
-  char *p;
+  const char *p;
   int *q;
 
   /* Read chars as long as they match the target string.
@@ -4019,9 +3832,8 @@ ffelex_hash_kludge (FILE *finput)
     }
 }
 
-#endif
 void
-ffelex_init_1 ()
+ffelex_init_1 (void)
 {
   unsigned int i;
 
@@ -4102,7 +3914,7 @@ ffelex_init_1 ()
    Must be called while lexer is active, obviously.  */
 
 bool
-ffelex_is_names_expected ()
+ffelex_is_names_expected (void)
 {
   return ffelex_names_;
 }
@@ -4111,7 +3923,7 @@ ffelex_is_names_expected ()
    ffelex_linecount_current_.  */
 
 char *
-ffelex_line ()
+ffelex_line (void)
 {
   return ffelex_card_image_;
 }
@@ -4123,7 +3935,7 @@ ffelex_line ()
    Must be called while lexer is active, obviously.  */
 
 ffewhereColumnNumber
-ffelex_line_length ()
+ffelex_line_length (void)
 {
   return ffelex_card_length_;
 }
@@ -4132,7 +3944,7 @@ ffelex_line_length ()
    is current.  */
 
 ffewhereLineNumber
-ffelex_line_number ()
+ffelex_line_number (void)
 {
   return ffelex_linecount_current_;
 }
@@ -4567,7 +4379,7 @@ ffelex_token_new_character (const char *s, ffewhereLine l, ffewhereColumn c)
 /* Make a new EOF token right after end of file.  */
 
 ffelexToken
-ffelex_token_new_eof ()
+ffelex_token_new_eof (void)
 {
   ffelexToken t;
 
@@ -4759,3 +4571,5 @@ ffelex_token_use (ffelexToken t)
   t->uses++;
   return t;
 }
+
+#include "gt-f-lex.h"