aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorDoug Evans <dje@gnu.org>1996-01-15 22:25:24 +0000
committerDoug Evans <dje@gnu.org>1996-01-15 22:25:24 +0000
commit05a81fe58ab528bf1fbb9d0d2deaab2285bdb518 (patch)
tree79c4f03f1d011640a7b270160132fb58e1333970 /gcc
parent9298a6b0eb75d3f025250cd3f626a7b74f470fe9 (diff)
downloadgcc-05a81fe58ab528bf1fbb9d0d2deaab2285bdb518.zip
gcc-05a81fe58ab528bf1fbb9d0d2deaab2285bdb518.tar.gz
gcc-05a81fe58ab528bf1fbb9d0d2deaab2285bdb518.tar.bz2
c-lex.c (check_newline): Pass character after `#pragma' to HANDLE_PRAGMA.
* 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c-common.c8
-rw-r--r--gcc/c-lex.c15
-rw-r--r--gcc/config/h8300/h8300.c48
-rw-r--r--gcc/config/h8300/h8300.h8
-rw-r--r--gcc/config/i960/i960.c11
-rw-r--r--gcc/config/i960/i960.h2
-rw-r--r--gcc/config/nextstep.c21
-rw-r--r--gcc/config/nextstep.h5
-rw-r--r--gcc/config/sh/sh.c44
-rw-r--r--gcc/config/sh/sh.h10
10 files changed, 89 insertions, 83 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index ad61319..58e9df0 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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';
diff --git a/gcc/c-lex.c b/gcc/c-lex.c
index 210c365..51479be 100644
--- a/gcc/c-lex.c
+++ b/gcc/c-lex.c
@@ -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;
}
diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c
index 8db3c36..f6a42eb 100644
--- a/gcc/config/h8300/h8300.c
+++ b/gcc/config/h8300/h8300.c
@@ -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;
}
diff --git a/gcc/config/h8300/h8300.h b/gcc/config/h8300/h8300.h
index 3996bf4..b146ed9 100644
--- a/gcc/config/h8300/h8300.h
+++ b/gcc/config/h8300/h8300.h
@@ -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)
diff --git a/gcc/config/i960/i960.c b/gcc/config/i960/i960.c
index cdd5913..72dabd2 100644
--- a/gcc/config/i960/i960.c
+++ b/gcc/config/i960/i960.c
@@ -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. */
diff --git a/gcc/config/i960/i960.h b/gcc/config/i960/i960.h
index c66f4a8..331e212 100644
--- a/gcc/config/i960/i960.h
+++ b/gcc/config/i960/i960.h
@@ -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. */
diff --git a/gcc/config/nextstep.c b/gcc/config/nextstep.c
index 823bcee..65bf16e 100644
--- a/gcc/config/nextstep.c
+++ b/gcc/config/nextstep.c
@@ -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);
}
diff --git a/gcc/config/nextstep.h b/gcc/config/nextstep.h
index 6e2e986..bfd039c 100644
--- a/gcc/config/nextstep.h
+++ b/gcc/config/nextstep.h
@@ -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. */
diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c
index 4d93874..81125b3 100644
--- a/gcc/config/sh/sh.c
+++ b/gcc/config/sh/sh.c
@@ -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;
}
diff --git a/gcc/config/sh/sh.h b/gcc/config/sh/sh.h
index 4d05a89..2c6f947 100644
--- a/gcc/config/sh/sh.h
+++ b/gcc/config/sh/sh.h
@@ -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. */