c-lex.c (check_newline): Pass character after `#pragma' to HANDLE_PRAGMA.
authorDoug Evans <dje@gnu.org>
Mon, 15 Jan 1996 22:25:24 +0000 (22:25 +0000)
committerDoug Evans <dje@gnu.org>
Mon, 15 Jan 1996 22:25:24 +0000 (22:25 +0000)
* c-lex.c (check_newline): Pass character after `#pragma' to
HANDLE_PRAGMA.  Don't call get_directive_line if at end of line.
* c-common.c (get_directive_line): Watch for EOF.
* h8300/h8300.h (HANDLE_PRAGMA): New argument `c'.
Must issue `return' now.
* i960/i960.h (HANDLE_PRAGMA): Likewise.
* sh/sh.h (HANDLE_PRAGMA): Likewise.
* nextstep.h (HANDLE_PRAGMA): Likewise.
* h8300/h8300.c (handle_pragma): New argument `ch'.
Simplify pragma processing.  Delete support for `#pragma section'.
* i960/i960.c (process_pragma): New argument `c'.  Change result to
terminating character.
* nextstep.c (handle_pragma): Likewise.
* sh/sh.c (handle_pragma): Likewise.  Also simplified.

From-SVN: r10999

gcc/c-common.c
gcc/c-lex.c
gcc/config/h8300/h8300.c
gcc/config/h8300/h8300.h
gcc/config/i960/i960.c
gcc/config/i960/i960.h
gcc/config/nextstep.c
gcc/config/nextstep.h
gcc/config/sh/sh.c
gcc/config/sh/sh.h

index ad613196b198f58ba63bf28476dd0d8e4086cbd7..58e9df02cd908c133426392bdb05a1c9f3e2546d 100644 (file)
@@ -2163,7 +2163,10 @@ truthvalue_conversion (expr)
    a part of the directive.
 
    The value is a string in a reusable buffer.  It remains valid
-   only until the next time this function is called.  */
+   only until the next time this function is called.
+
+   The terminating character ('\n' or EOF) is left in FINPUT for the
+   caller to re-read.  */
 
 char *
 get_directive_line (finput)
@@ -2207,7 +2210,8 @@ get_directive_line (finput)
        continue;
 
       /* Detect the end of the directive.  */
-      if (c == '\n' && looking_for == 0)
+      if (looking_for == 0
+         && (c == '\n' || c == EOF))
        {
           ungetc (c, finput);
          c = '\0';
index 210c365dda89ac31622d731688af9cb827e2f89f..51479beb53f3b31ca7c1595376da7f7f8e89b4f3 100644 (file)
@@ -1,5 +1,5 @@
 /* Lexical analyzer for C and Objective C.
-   Copyright (C) 1987, 88, 89, 92, 94, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1987, 88, 89, 92, 94, 95, 1996 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -402,7 +402,7 @@ check_newline ()
              return handle_sysv_pragma (finput, c);
 #else /* !HANDLE_SYSV_PRAGMA */
 #ifdef HANDLE_PRAGMA
-             HANDLE_PRAGMA (finput);
+             HANDLE_PRAGMA (finput, c);
 #endif /* HANDLE_PRAGMA */
              goto skipline;
 #endif /* !HANDLE_SYSV_PRAGMA */
@@ -419,7 +419,8 @@ check_newline ()
              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
            {
 #ifdef DWARF_DEBUGGING_INFO
-             if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+             if (c != '\n'
+                 && (debug_info_level == DINFO_LEVEL_VERBOSE)
                  && (write_symbols == DWARF_DEBUG))
                dwarfout_define (lineno, get_directive_line (finput));
 #endif /* DWARF_DEBUGGING_INFO */
@@ -435,7 +436,8 @@ check_newline ()
              && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
            {
 #ifdef DWARF_DEBUGGING_INFO
-             if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+             if (c != '\n'
+                 && (debug_info_level == DINFO_LEVEL_VERBOSE)
                  && (write_symbols == DWARF_DEBUG))
                dwarfout_undef (lineno, get_directive_line (finput));
 #endif /* DWARF_DEBUGGING_INFO */
@@ -674,9 +676,8 @@ linenum:
 
   /* skip the rest of this line.  */
  skipline:
-  if (c == '\n')
-    return c;
-  while ((c = getc (finput)) != EOF && c != '\n');
+  while (c != '\n' && c != EOF)
+    c = getc (finput);
   return c;
 }
 \f
index 8db3c3646e996ee8185b81e4fe1f5bf5cdb60437..f6a42ebdc2ba1afdc2d782dded27b27afb81987d 100644 (file)
@@ -548,57 +548,35 @@ eq_operator (x, mode)
    with this attribute may be safely used in an interrupt vector.  */
 
 int
-handle_pragma (file)
+handle_pragma (file, c)
      FILE *file;
+     int c;
 {
-  int c;
   char pbuf[20];
   int psize = 0;
 
-  c = getc (file);
   while (c == ' ' || c == '\t')
     c = getc (file);
 
-  if (c == '\n' || c == EOF)
-    return c;
-
-  /* The only pragmas we understand are interrupt and saveall.  */
-  while (psize < sizeof (pbuf) - 1
-        && isalpha (c))
+  if (c != '\n' & c != EOF)
     {
-      pbuf[psize++] = c;
-      c = getc (file);
-    }
-  pbuf[psize] = 0;
-
-  if (strcmp (pbuf, "interrupt") == 0)
-    pragma_interrupt = 1;
-
-  if (strcmp (pbuf, "saveall") == 0)
-    pragma_saveall = 1;
-
-  /* ??? This is deprecated.  Delete for gcc 2.8.  */
-  if (strcmp (pbuf, "section") == 0)
-    {
-      static int printed_p = 0;
-      if (!printed_p)
-       {
-         warning ("#pragma section is deprecated, use section attributes");
-         printed_p = 1;
-       }
-      while (c && !isalpha (c))
-       c = getc (file);
-      psize = 0;
       while (psize < sizeof (pbuf) - 1
-            && isalpha (c) || isdigit (c) || c == '_')
+            && isalpha (c))
        {
          pbuf[psize++] = c;
          c = getc (file);
        }
       pbuf[psize] = 0;
-      named_section (NULL_TREE, pbuf);
+
+      if (strcmp (pbuf, "interrupt") == 0)
+       pragma_interrupt = 1;
+      else if (strcmp (pbuf, "saveall") == 0)
+       pragma_saveall = 1;
+
+      while (c != '\n' && c != EOF)
+       c = getc (file);
     }
-  ungetc (c, file);
+
   return c;
 }
 \f
index 3996bf4b35f25989ae4a41867ada327ef5ac1bd0..b146ed907fcd1033b05358eff586a8c3aa7e8cb6 100644 (file)
@@ -1272,7 +1272,13 @@ do { char dstr[30];                                      \
 
 #define PRINT_OPERAND_ADDRESS(FILE, ADDR) print_operand_address (FILE, ADDR)
 
-#define HANDLE_PRAGMA(FILE) handle_pragma (FILE)
+/* Define this macro if you want to implement any pragmas.  If defined, it
+   should be a C statement to be executed when #pragma is seen.  The
+   argument STREAM is the stdio input stream from which the source
+   text can be read.  CH is the first character after the #pragma.  The
+   statement should execute a `return' with the terminating character found
+   (newline or EOF).  */
+#define HANDLE_PRAGMA(FILE, CH) return handle_pragma (FILE, CH)
 
 #define FINAL_PRESCAN_INSN(insn, operand, nop) final_prescan_insn (insn, operand,nop)
 
index cdd591396c4decfffc672c42b17f6d43b3ad8bb4..72dabd2d7db1d0671986b4a68f4d78c7cf836cf8 100644 (file)
@@ -89,14 +89,13 @@ static int ret_label = 0;
 /* ??? This is incomplete, since it does not handle all pragmas that the
    intel compilers understand.  */
 
-void
-process_pragma (finput)
+int
+process_pragma (finput, c)
      FILE *finput;
+     int c;
 {
-  int c;
   int i;
 
-  c = getc (finput);
   while (c == ' ' || c == '\t')
     c = getc (finput);
 
@@ -162,7 +161,9 @@ process_pragma (finput)
 
   /* Should be pragma 'far' or equivalent for callx/balx here.  */
 
-  ungetc (c, finput);
+  while (c != '\n' && c != EOF)
+    c = getc (finput);
+  return c;
 }
 
 /* Initialize variables before compiling any files.  */
index c66f4a801f4883b1e7098c2ba012e43ec1ab6ca7..331e212afda1b92ce07bce75f21263f0e56d4db2 100644 (file)
@@ -119,7 +119,7 @@ Boston, MA 02111-1307, USA.  */
   fprintf (asm_out_file, "\t.type\t0x%x;", (A & 0xf) + 2 * (A & ~0xf))
 
 /* Handle pragmas for compatibility with Intel's compilers.  */
-#define HANDLE_PRAGMA(FILE) process_pragma (FILE)
+#define HANDLE_PRAGMA(FILE, CH) return process_pragma (FILE, CH)
 
 /* Run-time compilation parameters selecting different hardware subsets.  */
 
index 823bceeffe3f820b7b76e0f6207988b2911e9541..65bf16e387ed5358fc1613a2d1e5759bbea06140 100644 (file)
@@ -1,5 +1,5 @@
 /* Functions for generic NeXT as target machine for GNU C compiler.
-   Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1989, 90-93, 1996 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -35,14 +35,17 @@ static int initial_optimize_flag;
 extern char *get_directive_line ();
 
 /* Called from check_newline via the macro HANDLE_PRAGMA.
-   FINPUT is the source file input stream.  */
+   FINPUT is the source file input stream.
+   CH is the first character after `#pragma'.
+   The result is the terminating character ('\n' or EOF).  */
 
-void
-handle_pragma (finput, get_line_function)
+int
+handle_pragma (finput, ch, get_line_function)
      FILE *finput;
+     int ch;
      char *(*get_line_function) ();
 {
-  register char *p = (*get_line_function) (finput);
+  register char *p;
 
   /* Record initial setting of optimize flag, so we can restore it.  */
   if (!pragma_initialized)
@@ -51,6 +54,11 @@ handle_pragma (finput, get_line_function)
       initial_optimize_flag = optimize;
     }
 
+  /* Nothing to do if #pragma is by itself.  */
+  if (ch == '\n' || ch == EOF)
+    return ch;
+
+  p = (*get_line_function) (finput);
   if (OPT_STRCMP ("CC_OPT_ON"))
     {
       optimize = 1, obey_regdecls = 0;
@@ -81,4 +89,7 @@ handle_pragma (finput, get_line_function)
     flag_writable_strings = 0;
   else if (OPT_STRCMP ("CC_NO_MACH_TEXT_SECTIONS"))
     flag_no_mach_text_sections = 1;
+
+  /* get_line_function must leave the last character read in FINPUT.  */
+  return getc (finput);
 }
index 6e2e986713ea590fefb0d70f10171e8e2fc2bad1..bfd039c22416b24ce44c4d4a82692a179ac6af53 100644 (file)
@@ -1,6 +1,6 @@
 /* nextstep.h -- operating system specific defines to be used when
    targeting GCC for NeXTSTEP.
-   Copyright (C) 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
+   Copyright (C) 1989, 90-93, 1996 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -240,7 +240,8 @@ Boston, MA 02111-1307, USA.  */
 /* How to parse #pragma's */
 
 #undef HANDLE_PRAGMA
-#define HANDLE_PRAGMA(finput) handle_pragma (finput, &get_directive_line)
+#define HANDLE_PRAGMA(finput, ch) \
+  return handle_pragma (finput, ch, &get_directive_line)
 
 /* Give methods pretty symbol names on NeXT. */
 
index 4d93874bb3ea85186078db434e573c2bcd1ac51b..81125b3e41c11a29cb023db6998538f56a86fa61 100644 (file)
@@ -1,5 +1,5 @@
 /* Output routines for GCC for Hitachi Super-H.
-   Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -23,6 +23,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include "config.h"
 
+#include <ctype.h>
 #include <stdio.h>
 
 #include "rtl.h"
@@ -2019,40 +2020,37 @@ initial_elimination_offset (from, to)
    compiler.  */
 
 int
-handle_pragma (file)
+handle_pragma (file, c)
      FILE *file;
+     int c;
 {
-  int c;
   char pbuf[200];
   int psize = 0;
 
-  c = getc (file);
   while (c == ' ' || c == '\t')
     c = getc (file);
 
-  if (c == '\n' || c == EOF)
-    return c;
-
-  while (psize < sizeof (pbuf) - 1 && c != '\n')
+  if (c != '\n' & c != EOF)
     {
-      pbuf[psize++] = c;
-      if (psize == 9 && strncmp (pbuf, "interrupt", 9) == 0)
-       {
-         pragma_interrupt = 1;
-         return ' ';
-       }
-      if (psize == 5 && strncmp (pbuf, "trapa", 5) == 0)
-       {
-         pragma_interrupt = pragma_trapa = 1;
-         return ' ';
-       }
-      if (psize == 15 && strncmp (pbuf, "nosave_low_regs", 15) == 0)
+      while (psize < sizeof (pbuf) - 1
+            && (isalpha (c) || c == '_'))
        {
-         pragma_nosave_low_regs = 1;
-         return ' ';
+         pbuf[psize++] = c;
+         c = getc (file);
        }
-      c = getc (file);
+      pbuf[psize] = 0;
+
+      if (strcmp (pbuf, "interrupt") == 0)
+       pragma_interrupt = 1;
+      else if (strcmp (pbuf, "trapa") == 0)
+       pragma_interrupt = pragma_trapa = 1;
+      else if (strcmp (pbuf, "nosave_low_regs") == 0)
+       pragma_nosave_low_regs = 1;
+
+      while (c != '\n' && c != EOF)
+       c = getc (file);
     }
+
   return c;
 }
 \f
index 4d05a893cc04a88deaceaba2079aafc21f4e1fbd..2c6f947c64bfef0a1552314211812fd27b462803 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions of target machine for GNU compiler for Hitachi Super-H.
-   Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
    Contributed by Steve Chamberlain (sac@cygnus.com).
    Improved by Jim Wilson (wilson@cygnus.com).
 
@@ -1388,7 +1388,13 @@ extern char *output_far_jump();
 
 #define TARGET_MEM_FUNCTIONS
 
-#define HANDLE_PRAGMA(finput) return handle_pragma (finput)
+/* Define this macro if you want to implement any pragmas.  If defined, it
+   should be a C statement to be executed when #pragma is seen.  The
+   argument STREAM is the stdio input stream from which the source
+   text can be read.  CH is the first character after the #pragma.  The
+   statement should execute a `return' with the terminating character found
+   (newline or EOF).  */
+#define HANDLE_PRAGMA(FILE, CH) return handle_pragma (FILE, CH)
 
 /* Set when processing a function with pragma interrupt turned on.  */