(process_pragma): Take the IDENTIFIER_POINTER tree
authorJim Wilson <wilson@gcc.gnu.org>
Wed, 17 Apr 1996 19:11:28 +0000 (12:11 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Wed, 17 Apr 1996 19:11:28 +0000 (12:11 -0700)
node instead of a character.

From-SVN: r11840

gcc/config/i960/i960.c
gcc/config/nextstep.c
gcc/config/sh/sh.c

index 02d60015cc06660dddf416d6e42827e6d020ace3..1399dc1f4055fc803092a939d641b6eb9001fac4 100644 (file)
@@ -90,28 +90,29 @@ static int ret_label = 0;
    intel compilers understand.  */
 
 int
-process_pragma (finput, c)
+process_pragma (finput, t)
      FILE *finput;
-     int c;
+     tree t;
 {
   int i;
+  register int c;
+  register char *pname;
 
-  while (c == ' ' || c == '\t')
-    c = getc (finput);
+  if (TREE_CODE (t) != IDENTIFIER_NODE)
+    return 0;
+
+  pname = IDENTIFIER_POINTER (t);
 
-  if (c == 'a'
-      && getc (finput) == 'l'
-      && getc (finput) == 'i'
-      && getc (finput) == 'g'
-      && getc (finput) == 'n'
-      && ((c = getc (finput)) == ' ' || c == '\t' || c == '\n'))
+  if (strcmp (pname, "align") == 0)
     {
       char buf[20];
       char *s = buf;
       int align;
 
-      while (c == ' ' || c == '\t')
+      do {
        c = getc (finput);
+      } while (c == ' ' || c == '\t');
+
       if (c == '(')
        c = getc (finput);
       while (c >= '0' && c <= '9')
@@ -157,13 +158,13 @@ process_pragma (finput, c)
         - missing identifier means next struct
 
         - alignment rules for bitfields need more investigation  */
+
+      return 1;
     }
 
   /* Should be pragma 'far' or equivalent for callx/balx here.  */
 
-  while (c != '\n' && c != EOF)
-    c = getc (finput);
-  return c;
+  return 0;
 }
 
 /* Initialize variables before compiling any files.  */
index 65bf16e387ed5358fc1613a2d1e5759bbea06140..3d6286dcb6b45813b6a1a25151d19d1f293cfcd0 100644 (file)
@@ -18,6 +18,8 @@ along with GNU CC; see the file COPYING.  If not, write to
 the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
+#include <tree.h>
+
 /* Make everything that used to go in the text section really go there.  */
 
 int flag_no_mach_text_sections = 0;
@@ -37,15 +39,15 @@ extern char *get_directive_line ();
 /* Called from check_newline via the macro HANDLE_PRAGMA.
    FINPUT is the source file input stream.
    CH is the first character after `#pragma'.
-   The result is the terminating character ('\n' or EOF).  */
+   The result is 1 if the pragma was handled.  */
 
 int
-handle_pragma (finput, ch, get_line_function)
+handle_pragma (finput, node)
      FILE *finput;
-     int ch;
-     char *(*get_line_function) ();
+     tree node;
 {
-  register char *p;
+  int retval = 0;
+  register char *pname;
 
   /* Record initial setting of optimize flag, so we can restore it.  */
   if (!pragma_initialized)
@@ -54,22 +56,24 @@ handle_pragma (finput, ch, get_line_function)
       initial_optimize_flag = optimize;
     }
 
-  /* Nothing to do if #pragma is by itself.  */
-  if (ch == '\n' || ch == EOF)
-    return ch;
+  if (TREE_CODE (node) != IDENTIFIER_NODE)
+    return 0;
+
+  pname = IDENTIFIER_POINTER (node);
 
-  p = (*get_line_function) (finput);
-  if (OPT_STRCMP ("CC_OPT_ON"))
+  if (strcmp (pname, "CC_OPT_ON") == 0)
     {
       optimize = 1, obey_regdecls = 0;
       warning ("optimization turned on");
+      retval = 1;
     }
-  else if (OPT_STRCMP ("CC_OPT_OFF"))
+  else if (strcmp (pname, "CC_OPT_OFF") == 0)
     {
       optimize = 0, obey_regdecls = 1;
       warning ("optimization turned off");
+      retval = 1;
     }
-  else if (OPT_STRCMP ("CC_OPT_RESTORE"))
+  else if (strcmp (pname, "CC_OPT_RESTORE") == 0)
     {
       extern int initial_optimize_flag;
 
@@ -82,14 +86,14 @@ handle_pragma (finput, ch, get_line_function)
          optimize = initial_optimize_flag;
        }
       warning ("optimization level restored");
+      retval = 1;
     }
-  else if (OPT_STRCMP ("CC_WRITABLE_STRINGS"))
-    flag_writable_strings = 1;
-  else if (OPT_STRCMP ("CC_NON_WRITABLE_STRINGS"))
-    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);
+  else if (strcmp (pname, "CC_WRITABLE_STRINGS") == 0)
+    flag_writable_strings = retval = 1;
+  else if (strcmp (pname, "CC_NON_WRITABLE_STRINGS") == 0)
+    flag_writable_strings = 0, retval = 1;
+  else if (strcmp (pname, "CC_NO_MACH_TEXT_SECTIONS") == 0)
+    flag_no_mach_text_sections = retval = 1;
+
+  return retval;
 }
index cae782a12d95cf7bd45d71db01a881686bad2222..764bf31d5e8203b1ee4ca2df3f4f6860c685f641 100644 (file)
@@ -2132,38 +2132,25 @@ initial_elimination_offset (from, to)
    compiler.  */
 
 int
-handle_pragma (file, c)
+handle_pragma (file, t)
      FILE *file;
-     int c;
+     tree t;
 {
-  char pbuf[200];
-  int psize = 0;
+  int retval = 0;
+  register char *pname;
 
-  while (c == ' ' || c == '\t')
-    c = getc (file);
-
-  if (c != '\n' & c != EOF)
-    {
-      while (psize < sizeof (pbuf) - 1
-            && (isalpha (c) || c == '_'))
-       {
-         pbuf[psize++] = c;
-         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;
+  if (TREE_CODE (t) != IDENTIFIER_NODE)
+    return 0;
 
-      while (c != '\n' && c != EOF)
-       c = getc (file);
-    }
+  pname = IDENTIFIER_POINTER (t);
+  if (strcmp (pname, "interrupt") == 0)
+    pragma_interrupt = retval = 1;
+  else if (strcmp (pname, "trapa") == 0)
+    pragma_interrupt = pragma_trapa = retval = 1;
+  else if (strcmp (pname, "nosave_low_regs") == 0)
+    pragma_nosave_low_regs = retval = 1;
 
-  return c;
+  return retval;
 }
 \f
 /* Predicates used by the templates.  */