From 119d0c36a6b2f36bd3b3db5c8c5c486016767e25 Mon Sep 17 00:00:00 2001 From: Jim Wilson Date: Wed, 17 Apr 1996 12:11:28 -0700 Subject: [PATCH] (process_pragma): Take the IDENTIFIER_POINTER tree node instead of a character. From-SVN: r11840 --- gcc/config/i960/i960.c | 29 +++++++++++++------------- gcc/config/nextstep.c | 46 +++++++++++++++++++++++------------------- gcc/config/sh/sh.c | 41 +++++++++++++------------------------ 3 files changed, 54 insertions(+), 62 deletions(-) diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c index 02d60015cc0..1399dc1f405 100644 --- a/gcc/config/i960/i960.c +++ b/gcc/config/i960/i960.c @@ -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. */ diff --git a/gcc/config/nextstep.c b/gcc/config/nextstep.c index 65bf16e387e..3d6286dcb6b 100644 --- a/gcc/config/nextstep.c +++ b/gcc/config/nextstep.c @@ -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 + /* 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; } diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index cae782a12d9..764bf31d5e8 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -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; } /* Predicates used by the templates. */ -- 2.30.2