Commit ef6e958a by Neil Booth Committed by Neil Booth

Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h are also on line-map.h.

	* Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h
	are also on line-map.h.
	* cppfiles.c (stack_include_file): Update.
	* cpphash.h (struct cpp_buffer): New member return_at_eof.
	(_cpp_pop_buffer): New.
	* cppinit.c (cpp_destroy, cpp_finish): Update.
	(do_includes): Mark each buffer to return at EOF.
	* cpplex.c (_cpp_lex_token): Pop buffers at EOF.  Continue or
	return as requested.
	* cpplib.c (run_directive, do_line, cpp_push_buffer): Update.
	(cpp_pop_buffer): Rename _cpp_pop_buffer.  Stop skipping.
	* cpplib.h (cpp_pop_buffer): Remove.
	(cpp_scan_buffer_nooutput): Rename cpp_scan_nooutput.
	* cppmacro.c (cpp_scan_buffer_nooutput): Similarly.  No need to pop
	buffers.
	* cppmain.c (scan_buffer): Rename scan_translation_unit.  No need
	to pop buffers.
	(do_preprocessing): Update.
	* fix-header.c (read_scan_file): Update.  No need to pop buffers.
	* c-parse.in (_yylex): Similarly.
	* scan-decls.c (scan_decls): Similarly.
	* line-map.h: Update comments.

	* cp/spew.c (read_token): No need to pop buffers.

	* objc/Make-lang.in (objc-act.o): Update dependencies.

From-SVN: r44634
parent 03997728
2001-08-04 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* Makefile.in (CPPLIB_H): New, so that dependencies on cpplib.h
are also on line-map.h.
* cppfiles.c (stack_include_file): Update.
* cpphash.h (struct cpp_buffer): New member return_at_eof.
(_cpp_pop_buffer): New.
* cppinit.c (cpp_destroy, cpp_finish): Update.
(do_includes): Mark each buffer to return at EOF.
* cpplex.c (_cpp_lex_token): Pop buffers at EOF. Continue or
return as requested.
* cpplib.c (run_directive, do_line, cpp_push_buffer): Update.
(cpp_pop_buffer): Rename _cpp_pop_buffer. Stop skipping.
* cpplib.h (cpp_pop_buffer): Remove.
(cpp_scan_buffer_nooutput): Rename cpp_scan_nooutput.
* cppmacro.c (cpp_scan_buffer_nooutput): Similarly. No need to pop
buffers.
* cppmain.c (scan_buffer): Rename scan_translation_unit. No need
to pop buffers.
(do_preprocessing): Update.
* fix-header.c (read_scan_file): Update. No need to pop buffers.
* c-parse.in (_yylex): Similarly.
* scan-decls.c (scan_decls): Similarly.
* line-map.h: Update comments.
* objc/Make-lang.in (objc-act.o): Update dependencies.
2001-08-04 Stephane Carrez <Stephane.Carrez@worldnet.fr> 2001-08-04 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* config/m68hc11/m68hc11.md ("cmphi_1", "cmpqi_1"): Allow memory * config/m68hc11/m68hc11.md ("cmphi_1", "cmpqi_1"): Allow memory
......
...@@ -579,6 +579,7 @@ C_COMMON_H = c-common.h $(SPLAY_TREE_H) ...@@ -579,6 +579,7 @@ C_COMMON_H = c-common.h $(SPLAY_TREE_H)
C_TREE_H = c-tree.h $(C_COMMON_H) C_TREE_H = c-tree.h $(C_COMMON_H)
SYSTEM_H = system.h hwint.h $(srcdir)/../include/libiberty.h SYSTEM_H = system.h hwint.h $(srcdir)/../include/libiberty.h
PREDICT_H = predict.h predict.def PREDICT_H = predict.h predict.def
CPPLIB_H = cpplib.h line-map.h
# sed inserts variable overrides after the following line. # sed inserts variable overrides after the following line.
####target overrides ####target overrides
...@@ -1152,7 +1153,7 @@ s-crt0: $(CRT0_S) $(MCRT0_S) $(GCC_PASSES) $(CONFIG_H) ...@@ -1152,7 +1153,7 @@ s-crt0: $(CRT0_S) $(MCRT0_S) $(GCC_PASSES) $(CONFIG_H)
c-errors.o: c-errors.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) flags.h \ c-errors.o: c-errors.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) flags.h \
diagnostic.h $(TM_P_H) diagnostic.h $(TM_P_H)
c-parse.o : $(srcdir)/c-parse.c $(CONFIG_H) $(TREE_H) c-lex.h $(GGC_H) intl.h \ c-parse.o : $(srcdir)/c-parse.c $(CONFIG_H) $(TREE_H) c-lex.h $(GGC_H) intl.h \
$(C_TREE_H) input.h flags.h $(SYSTEM_H) toplev.h output.h cpplib.h \ $(C_TREE_H) input.h flags.h $(SYSTEM_H) toplev.h output.h $(CPPLIB_H) \
diagnostic.h diagnostic.h
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/c-parse.c $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -c $(srcdir)/c-parse.c
...@@ -1177,7 +1178,7 @@ c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \ ...@@ -1177,7 +1178,7 @@ c-lang.o : c-lang.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \ c-lex.o : c-lex.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(RTL_H) c-lex.h \
debug.h $(C_TREE_H) \ debug.h $(C_TREE_H) \
c-pragma.h input.h intl.h flags.h toplev.h output.h \ c-pragma.h input.h intl.h flags.h toplev.h output.h \
mbchar.h cpplib.h $(EXPR_H) $(TM_P_H) mbchar.h $(CPPLIB_H) $(EXPR_H) $(TM_P_H)
c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \ c-aux-info.o : c-aux-info.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(C_TREE_H) \
flags.h toplev.h flags.h toplev.h
c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h toplev.h c-convert.o : c-convert.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) flags.h toplev.h
...@@ -1937,7 +1938,7 @@ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \ ...@@ -1937,7 +1938,7 @@ LIBCPP_OBJS = cpplib.o cpplex.o cppmacro.o cppexp.o cppfiles.o \
cpphash.o cpperror.o cppinit.o cppdefault.o \ cpphash.o cpperror.o cppinit.o cppdefault.o \
hashtable.o line-map.o mkdeps.o prefix.o version.o mbchar.o hashtable.o line-map.o mkdeps.o prefix.o version.o mbchar.o
LIBCPP_DEPS = cpplib.h cpphash.h line-map.h hashtable.h intl.h \ LIBCPP_DEPS = $(CPPLIB_H) cpphash.h line-map.h hashtable.h intl.h \
$(OBSTACK_H) $(SYSTEM_H) $(OBSTACK_H) $(SYSTEM_H)
# Most of the other archives built/used by this makefile are for # Most of the other archives built/used by this makefile are for
...@@ -1951,7 +1952,7 @@ cpp0$(exeext): cppmain.o intl.o libcpp.a $(LIBDEPS) ...@@ -1951,7 +1952,7 @@ cpp0$(exeext): cppmain.o intl.o libcpp.a $(LIBDEPS)
$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cpp0$(exeext) cppmain.o \ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o cpp0$(exeext) cppmain.o \
intl.o libcpp.a $(LIBS) intl.o libcpp.a $(LIBS)
cppmain.o: cppmain.c $(CONFIG_H) cpplib.h intl.h $(SYSTEM_H) cppmain.o: cppmain.c $(CONFIG_H) $(CPPLIB_H) intl.h $(SYSTEM_H)
cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS) cpperror.o: cpperror.c $(CONFIG_H) $(LIBCPP_DEPS)
cppexp.o: cppexp.c $(CONFIG_H) $(LIBCPP_DEPS) cppexp.o: cppexp.c $(CONFIG_H) $(LIBCPP_DEPS)
...@@ -2194,10 +2195,10 @@ fix-header$(build_exeext): fix-header.o scan-decls.o scan.o xsys-protos.h \ ...@@ -2194,10 +2195,10 @@ fix-header$(build_exeext): fix-header.o scan-decls.o scan.o xsys-protos.h \
scan-decls.o scan.o libcpp.a $(LIBS) scan-decls.o scan.o libcpp.a $(LIBS)
fix-header.o: fix-header.c $(OBSTACK_H) scan.h \ fix-header.o: fix-header.c $(OBSTACK_H) scan.h \
xsys-protos.h $(HCONFIG_H) $(SYSTEM_H) cpplib.h xsys-protos.h $(HCONFIG_H) $(SYSTEM_H) $(CPPLIB_H)
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/fix-header.c $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/fix-header.c
scan-decls.o: scan-decls.c scan.h cpplib.h $(HCONFIG_H) $(SYSTEM_H) scan-decls.o: scan-decls.c scan.h $(CPPLIB_H) $(HCONFIG_H) $(SYSTEM_H)
$(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/scan-decls.c $(HOST_CC) -c $(HOST_CFLAGS) $(HOST_CPPFLAGS) $(INCLUDES) $(srcdir)/scan-decls.c
# stmp-fixproto depends on this, not on fix-header directly. # stmp-fixproto depends on this, not on fix-header directly.
......
...@@ -3767,9 +3767,7 @@ _yylex () ...@@ -3767,9 +3767,7 @@ _yylex ()
case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';'; case CPP_SEMICOLON: OBJC_NEED_RAW_IDENTIFIER (0); return ';';
case CPP_EOF: case CPP_EOF:
if (cpp_pop_buffer (parse_in) == 0) return 0;
return 0;
goto get_next;
case CPP_NAME: case CPP_NAME:
return yylexname (); return yylexname ();
......
2001-08-04 Neil Booth <neil@cat.daikokuya.demon.co.uk>
* cp/spew.c (read_token): No need to pop buffers.
2001-08-02 Stan Shebs <shebs@apple.com> 2001-08-02 Stan Shebs <shebs@apple.com>
* cp-tree.h (FNADDR_FROM_VTABLE_ENTRY): Remove, no longer used. * cp-tree.h (FNADDR_FROM_VTABLE_ENTRY): Remove, no longer used.
......
...@@ -331,8 +331,6 @@ read_token (t) ...@@ -331,8 +331,6 @@ read_token (t)
#undef YYCODE #undef YYCODE
case CPP_EOF: case CPP_EOF:
if (cpp_pop_buffer (parse_in) != 0)
goto retry;
t->yychar = 0; t->yychar = 0;
break; break;
......
...@@ -326,7 +326,7 @@ stack_include_file (pfile, inc) ...@@ -326,7 +326,7 @@ stack_include_file (pfile, inc)
} }
/* Push a buffer. */ /* Push a buffer. */
fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, inc->name); fp = cpp_push_buffer (pfile, inc->buffer, len, BUF_FILE, inc->name, 0);
fp->inc = inc; fp->inc = inc;
fp->inc->refcnt++; fp->inc->refcnt++;
fp->sysp = sysp; fp->sysp = sysp;
......
...@@ -226,6 +226,11 @@ struct cpp_buffer ...@@ -226,6 +226,11 @@ struct cpp_buffer
include files has been calculated and stored in "dir" below. */ include files has been calculated and stored in "dir" below. */
unsigned char search_cached; unsigned char search_cached;
/* At EOF, a buffer is automatically popped. If RETURN_AT_EOF is
true, a CPP_EOF token is then returned. Otherwise, the next
token from the enclosing buffer is returned. */
bool return_at_eof;
/* Buffer type. */ /* Buffer type. */
ENUM_BITFIELD (cpp_buffer_type) type : 8; ENUM_BITFIELD (cpp_buffer_type) type : 8;
...@@ -441,6 +446,7 @@ extern void _cpp_do__Pragma PARAMS ((cpp_reader *)); ...@@ -441,6 +446,7 @@ extern void _cpp_do__Pragma PARAMS ((cpp_reader *));
extern void _cpp_init_directives PARAMS ((cpp_reader *)); extern void _cpp_init_directives PARAMS ((cpp_reader *));
extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *)); extern void _cpp_init_internal_pragmas PARAMS ((cpp_reader *));
extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason)); extern void _cpp_do_file_change PARAMS ((cpp_reader *, enum lc_reason));
extern void _cpp_pop_buffer PARAMS ((cpp_reader *));
/* Utility routines and macros. */ /* Utility routines and macros. */
#define DSC(str) (const U_CHAR *)str, sizeof str - 1 #define DSC(str) (const U_CHAR *)str, sizeof str - 1
......
...@@ -555,7 +555,7 @@ cpp_destroy (pfile) ...@@ -555,7 +555,7 @@ cpp_destroy (pfile)
cpp_context *context, *contextn; cpp_context *context, *contextn;
while (CPP_BUFFER (pfile) != NULL) while (CPP_BUFFER (pfile) != NULL)
cpp_pop_buffer (pfile); _cpp_pop_buffer (pfile);
if (pfile->macro_buffer) if (pfile->macro_buffer)
{ {
...@@ -883,7 +883,10 @@ do_includes (pfile, p, scan) ...@@ -883,7 +883,10 @@ do_includes (pfile, p, scan)
header.val.str.text = (const unsigned char *) p->arg; header.val.str.text = (const unsigned char *) p->arg;
header.val.str.len = strlen (p->arg); header.val.str.len = strlen (p->arg);
if (_cpp_execute_include (pfile, &header, IT_CMDLINE) && scan) if (_cpp_execute_include (pfile, &header, IT_CMDLINE) && scan)
cpp_scan_buffer_nooutput (pfile, 0); {
pfile->buffer->return_at_eof = true;
cpp_scan_nooutput (pfile);
}
} }
q = p->next; q = p->next;
free (p); free (p);
...@@ -1011,7 +1014,7 @@ cpp_finish (pfile) ...@@ -1011,7 +1014,7 @@ cpp_finish (pfile)
{ {
cpp_ice (pfile, "buffers still stacked in cpp_finish"); cpp_ice (pfile, "buffers still stacked in cpp_finish");
while (CPP_BUFFER (pfile)) while (CPP_BUFFER (pfile))
cpp_pop_buffer (pfile); _cpp_pop_buffer (pfile);
} }
/* Don't write the deps file if preprocessing has failed. */ /* Don't write the deps file if preprocessing has failed. */
......
...@@ -893,16 +893,23 @@ _cpp_lex_token (pfile, result) ...@@ -893,16 +893,23 @@ _cpp_lex_token (pfile, result)
switch (c) switch (c)
{ {
case EOF: case EOF:
/* Non-empty files should end in a newline. Checking "bol" too if (!pfile->state.in_directive)
prevents multiple warnings when hitting the EOF more than {
once, like in a directive. Don't warn for command line and unsigned char ret = pfile->buffer->return_at_eof;
_Pragma buffers. */
if (pfile->lexer_pos.col != 0 && !bol && !buffer->from_stage3) /* Non-empty files should end in a newline. Don't warn for
cpp_pedwarn (pfile, "no newline at end of file"); command line and _Pragma buffers. */
if (pfile->lexer_pos.col != 0 && !buffer->from_stage3)
cpp_pedwarn (pfile, "no newline at end of file");
_cpp_pop_buffer (pfile);
if (pfile->buffer && !ret)
{
bol = 1;
goto done_directive;
}
}
pfile->state.next_bol = 1; pfile->state.next_bol = 1;
pfile->state.skipping = 0; /* In case missing #endif. */
result->type = CPP_EOF; result->type = CPP_EOF;
/* Don't do MI optimisation. */
return; return;
case ' ': case '\t': case '\f': case '\v': case '\0': case ' ': case '\t': case '\f': case '\v': case '\0':
......
...@@ -397,7 +397,7 @@ run_directive (pfile, dir_no, type, buf, count) ...@@ -397,7 +397,7 @@ run_directive (pfile, dir_no, type, buf, count)
unsigned int output_line = pfile->lexer_pos.output_line; unsigned int output_line = pfile->lexer_pos.output_line;
cpp_buffer *buffer; cpp_buffer *buffer;
buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 0); buffer = cpp_push_buffer (pfile, (const U_CHAR *) buf, count, type, 0, 1);
if (dir_no == T_PRAGMA) if (dir_no == T_PRAGMA)
{ {
...@@ -414,8 +414,7 @@ run_directive (pfile, dir_no, type, buf, count) ...@@ -414,8 +414,7 @@ run_directive (pfile, dir_no, type, buf, count)
pfile->state.prevent_expansion--; pfile->state.prevent_expansion--;
check_eol (pfile); check_eol (pfile);
end_directive (pfile, 1); end_directive (pfile, 1);
_cpp_pop_buffer (pfile);
cpp_pop_buffer (pfile);
} }
/* Checks for validity the macro name in #define, #undef, #ifdef and /* Checks for validity the macro name in #define, #undef, #ifdef and
...@@ -770,7 +769,7 @@ do_line (pfile) ...@@ -770,7 +769,7 @@ do_line (pfile)
if (reason == LC_ENTER) if (reason == LC_ENTER)
{ {
/* Fake a buffer stack for diagnostics. */ /* Fake a buffer stack for diagnostics. */
cpp_push_buffer (pfile, 0, 0, BUF_FAKE, fname); cpp_push_buffer (pfile, 0, 0, BUF_FAKE, fname, 0);
/* Fake an include for cpp_included. */ /* Fake an include for cpp_included. */
_cpp_fake_include (pfile, fname); _cpp_fake_include (pfile, fname);
buffer = pfile->buffer; buffer = pfile->buffer;
...@@ -782,7 +781,7 @@ do_line (pfile) ...@@ -782,7 +781,7 @@ do_line (pfile)
buffer->nominal_fname); buffer->nominal_fname);
else else
{ {
cpp_pop_buffer (pfile); _cpp_pop_buffer (pfile);
buffer = pfile->buffer; buffer = pfile->buffer;
#ifdef ENABLE_CHECKING #ifdef ENABLE_CHECKING
if (strcmp (buffer->nominal_fname, fname)) if (strcmp (buffer->nominal_fname, fname))
...@@ -1775,12 +1774,13 @@ cpp_set_callbacks (pfile, cb) ...@@ -1775,12 +1774,13 @@ cpp_set_callbacks (pfile, cb)
doesn't fail. It does not generate a file change call back; that doesn't fail. It does not generate a file change call back; that
is the responsibility of the caller. */ is the responsibility of the caller. */
cpp_buffer * cpp_buffer *
cpp_push_buffer (pfile, buffer, len, type, filename) cpp_push_buffer (pfile, buffer, len, type, filename, return_at_eof)
cpp_reader *pfile; cpp_reader *pfile;
const U_CHAR *buffer; const U_CHAR *buffer;
size_t len; size_t len;
enum cpp_buffer_type type; enum cpp_buffer_type type;
const char *filename; const char *filename;
int return_at_eof;
{ {
cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer); cpp_buffer *new = xobnew (&pfile->buffer_ob, cpp_buffer);
...@@ -1826,6 +1826,7 @@ cpp_push_buffer (pfile, buffer, len, type, filename) ...@@ -1826,6 +1826,7 @@ cpp_push_buffer (pfile, buffer, len, type, filename)
new->pfile = pfile; new->pfile = pfile;
new->include_stack_listed = 0; new->include_stack_listed = 0;
new->lineno = 1; new->lineno = 1;
new->return_at_eof = return_at_eof;
pfile->state.next_bol = 1; pfile->state.next_bol = 1;
pfile->buffer_stack_depth++; pfile->buffer_stack_depth++;
...@@ -1837,8 +1838,8 @@ cpp_push_buffer (pfile, buffer, len, type, filename) ...@@ -1837,8 +1838,8 @@ cpp_push_buffer (pfile, buffer, len, type, filename)
/* If called from do_line, pops a single buffer. Otherwise pops all /* If called from do_line, pops a single buffer. Otherwise pops all
buffers until a real file is reached. Generates appropriate buffers until a real file is reached. Generates appropriate
call-backs. */ call-backs. */
cpp_buffer * void
cpp_pop_buffer (pfile) _cpp_pop_buffer (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
cpp_buffer *buffer; cpp_buffer *buffer;
...@@ -1884,7 +1885,8 @@ cpp_pop_buffer (pfile) ...@@ -1884,7 +1885,8 @@ cpp_pop_buffer (pfile)
} }
obstack_free (&pfile->buffer_ob, buffer); obstack_free (&pfile->buffer_ob, buffer);
return pfile->buffer;
pfile->state.skipping = 0; /* In case missing #endif. */
} }
void void
......
...@@ -554,8 +554,7 @@ extern void cpp_unassert PARAMS ((cpp_reader *, const char *)); ...@@ -554,8 +554,7 @@ extern void cpp_unassert PARAMS ((cpp_reader *, const char *));
extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *, extern cpp_buffer *cpp_push_buffer PARAMS ((cpp_reader *,
const unsigned char *, size_t, const unsigned char *, size_t,
enum cpp_buffer_type, enum cpp_buffer_type,
const char *)); const char *, int));
extern cpp_buffer *cpp_pop_buffer PARAMS ((cpp_reader *));
extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int)); extern int cpp_defined PARAMS ((cpp_reader *, const unsigned char *, int));
/* N.B. The error-message-printer prototypes have not been nicely /* N.B. The error-message-printer prototypes have not been nicely
...@@ -611,7 +610,7 @@ extern void cpp_forall_identifiers PARAMS ((cpp_reader *, ...@@ -611,7 +610,7 @@ extern void cpp_forall_identifiers PARAMS ((cpp_reader *,
cpp_cb, void *)); cpp_cb, void *));
/* In cppmacro.c */ /* In cppmacro.c */
extern void cpp_scan_buffer_nooutput PARAMS ((cpp_reader *, int)); extern void cpp_scan_nooutput PARAMS ((cpp_reader *));
extern void cpp_start_lookahead PARAMS ((cpp_reader *)); extern void cpp_start_lookahead PARAMS ((cpp_reader *));
extern void cpp_stop_lookahead PARAMS ((cpp_reader *, int)); extern void cpp_stop_lookahead PARAMS ((cpp_reader *, int));
extern int cpp_sys_macro_p PARAMS ((cpp_reader *)); extern int cpp_sys_macro_p PARAMS ((cpp_reader *));
......
...@@ -1010,18 +1010,14 @@ cpp_sys_macro_p (pfile) ...@@ -1010,18 +1010,14 @@ cpp_sys_macro_p (pfile)
/* Read each token in, until EOF. Directives are transparently /* Read each token in, until EOF. Directives are transparently
processed. */ processed. */
void void
cpp_scan_buffer_nooutput (pfile, all_buffers) cpp_scan_nooutput (pfile)
cpp_reader *pfile; cpp_reader *pfile;
int all_buffers;
{ {
cpp_token token; cpp_token token;
cpp_buffer *buffer = all_buffers ? 0: pfile->buffer->prev;
do do
do cpp_get_token (pfile, &token);
cpp_get_token (pfile, &token); while (token.type != CPP_EOF);
while (token.type != CPP_EOF);
while (cpp_pop_buffer (pfile) != buffer);
} }
/* Lookahead handling. */ /* Lookahead handling. */
......
...@@ -44,7 +44,7 @@ static void do_preprocessing PARAMS ((int, char **)); ...@@ -44,7 +44,7 @@ static void do_preprocessing PARAMS ((int, char **));
static void setup_callbacks PARAMS ((void)); static void setup_callbacks PARAMS ((void));
/* General output routines. */ /* General output routines. */
static void scan_buffer PARAMS ((cpp_reader *)); static void scan_translation_unit PARAMS ((cpp_reader *));
static void check_multiline_token PARAMS ((cpp_string *)); static void check_multiline_token PARAMS ((cpp_string *));
static int printer_init PARAMS ((cpp_reader *)); static int printer_init PARAMS ((cpp_reader *));
static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *)); static int dump_macro PARAMS ((cpp_reader *, cpp_hashnode *, void *));
...@@ -151,11 +151,11 @@ do_preprocessing (argc, argv) ...@@ -151,11 +151,11 @@ do_preprocessing (argc, argv)
if (cpp_start_read (pfile, options->in_fname)) if (cpp_start_read (pfile, options->in_fname))
{ {
/* A successful cpp_start_read guarantees that we can call /* A successful cpp_start_read guarantees that we can call
cpp_scan_buffer_nooutput or cpp_get_token next. */ cpp_scan_nooutput or cpp_get_token next. */
if (options->no_output) if (options->no_output)
cpp_scan_buffer_nooutput (pfile, 1); cpp_scan_nooutput (pfile);
else else
scan_buffer (pfile); scan_translation_unit (pfile);
/* -dM command line option. Should this be in cpp_finish? */ /* -dM command line option. Should this be in cpp_finish? */
if (options->dump_macros == dump_only) if (options->dump_macros == dump_only)
...@@ -200,60 +200,56 @@ setup_callbacks () ...@@ -200,60 +200,56 @@ setup_callbacks ()
/* Writes out the preprocessed file. Alternates between two tokens, /* Writes out the preprocessed file. Alternates between two tokens,
so that we can avoid accidental token pasting. */ so that we can avoid accidental token pasting. */
static void static void
scan_buffer (pfile) scan_translation_unit (pfile)
cpp_reader *pfile; cpp_reader *pfile;
{ {
unsigned int index, line; unsigned int index, line;
cpp_token tokens[2], *token; cpp_token tokens[2], *token;
do for (index = 0;; index = 1 - index)
{ {
for (index = 0;; index = 1 - index) token = &tokens[index];
{ cpp_get_token (pfile, token);
token = &tokens[index];
cpp_get_token (pfile, token);
if (token->type == CPP_EOF) if (token->type == CPP_EOF)
break; break;
line = cpp_get_line (pfile)->output_line; line = cpp_get_line (pfile)->output_line;
if (print.lineno != line) if (print.lineno != line)
{
unsigned int col = cpp_get_line (pfile)->col;
/* Supply enough whitespace to put this token in its original
column. Don't bother trying to reconstruct tabs; we can't
get it right in general, and nothing ought to care. (Yes,
some things do care; the fault lies with them.) */
maybe_print_line (line);
if (col > 1)
{ {
unsigned int col = cpp_get_line (pfile)->col; if (token->flags & PREV_WHITE)
col--;
/* Supply enough whitespace to put this token in its original while (--col)
column. Don't bother trying to reconstruct tabs; we can't putc (' ', print.outf);
get it right in general, and nothing ought to care. (Yes,
some things do care; the fault lies with them.) */
maybe_print_line (line);
if (col > 1)
{
if (token->flags & PREV_WHITE)
col--;
while (--col)
putc (' ', print.outf);
}
} }
else if ((token->flags & (PREV_WHITE | AVOID_LPASTE))
== AVOID_LPASTE
&& cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE;
/* Special case '# <directive name>': insert a space between
the # and the token. This will prevent it from being
treated as a directive when this code is re-preprocessed.
XXX Should do this only at the beginning of a line, but how? */
else if (token->type == CPP_NAME && token->val.node->directive_index
&& tokens[1 - index].type == CPP_HASH)
token->flags |= PREV_WHITE;
cpp_output_token (token, print.outf);
print.printed = 1;
if (token->type == CPP_STRING || token->type == CPP_WSTRING
|| token->type == CPP_COMMENT)
check_multiline_token (&token->val.str);
} }
else if ((token->flags & (PREV_WHITE | AVOID_LPASTE))
== AVOID_LPASTE
&& cpp_avoid_paste (pfile, &tokens[1 - index], token))
token->flags |= PREV_WHITE;
/* Special case '# <directive name>': insert a space between
the # and the token. This will prevent it from being
treated as a directive when this code is re-preprocessed.
XXX Should do this only at the beginning of a line, but how? */
else if (token->type == CPP_NAME && token->val.node->directive_index
&& tokens[1 - index].type == CPP_HASH)
token->flags |= PREV_WHITE;
cpp_output_token (token, print.outf);
print.printed = 1;
if (token->type == CPP_STRING || token->type == CPP_WSTRING
|| token->type == CPP_COMMENT)
check_multiline_token (&token->val.str);
} }
while (cpp_pop_buffer (pfile) != 0);
} }
/* Adjust print.lineno for newlines embedded in tokens. */ /* Adjust print.lineno for newlines embedded in tokens. */
......
...@@ -658,7 +658,7 @@ read_scan_file (in_fname, argc, argv) ...@@ -658,7 +658,7 @@ read_scan_file (in_fname, argc, argv)
/* Scan the macro expansion of "getchar();". */ /* Scan the macro expansion of "getchar();". */
cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1, cpp_push_buffer (scan_in, getchar_call, sizeof(getchar_call) - 1,
BUF_BUILTIN, in_fname); BUF_BUILTIN, in_fname, 1);
for (;;) for (;;)
{ {
cpp_token t; cpp_token t;
...@@ -669,7 +669,6 @@ read_scan_file (in_fname, argc, argv) ...@@ -669,7 +669,6 @@ read_scan_file (in_fname, argc, argv)
else if (cpp_ideq (&t, "_filbuf")) else if (cpp_ideq (&t, "_filbuf"))
seen_filbuf++; seen_filbuf++;
} }
cpp_pop_buffer (scan_in);
if (seen_filbuf) if (seen_filbuf)
{ {
......
...@@ -25,7 +25,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -25,7 +25,9 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/* The logical line FROM_LINE maps to physical source file TO_FILE at /* The logical line FROM_LINE maps to physical source file TO_FILE at
line TO_LINE, and subsequently one-to-one until the next line_map line TO_LINE, and subsequently one-to-one until the next line_map
structure in the set. */ structure in the set. INCLUDED_FROM is an index into the set that
gives the line mapping at whose end the current one was included.
File(s) at the bottom of the include stack have this set to -1. */
struct line_map struct line_map
{ {
const char *to_file; const char *to_file;
...@@ -34,7 +36,7 @@ struct line_map ...@@ -34,7 +36,7 @@ struct line_map
int included_from; int included_from;
}; };
/* Contains a sequence of chronological line_map structures. */ /* A set of chronological line_map structures. */
struct line_maps struct line_maps
{ {
struct line_map *maps; struct line_map *maps;
...@@ -75,6 +77,7 @@ extern struct line_map *lookup_line ...@@ -75,6 +77,7 @@ extern struct line_map *lookup_line
of the #include, or other directive, that caused a map change. */ of the #include, or other directive, that caused a map change. */
#define LAST_SOURCE_LINE(MAP) SOURCE_LINE (MAP, (MAP)[1].from_line - 1) #define LAST_SOURCE_LINE(MAP) SOURCE_LINE (MAP, (MAP)[1].from_line - 1)
/* Non-zero if the map is at the bottom of the include stack. */
#define MAIN_FILE_P(MAP) ((MAP)->included_from < 0) #define MAIN_FILE_P(MAP) ((MAP)->included_from < 0)
#endif /* !GCC_LINE_MAP_H */ #endif /* !GCC_LINE_MAP_H */
...@@ -59,7 +59,7 @@ objc-parse.o : $(srcdir)/objc/objc-parse.c \ ...@@ -59,7 +59,7 @@ objc-parse.o : $(srcdir)/objc/objc-parse.c \
$(CONFIG_H) $(TREE_H) $(srcdir)/toplev.h $(srcdir)/ggc.h \ $(CONFIG_H) $(TREE_H) $(srcdir)/toplev.h $(srcdir)/ggc.h \
$(srcdir)/c-lex.h $(srcdir)/c-tree.h $(srcdir)/c-common.h \ $(srcdir)/c-lex.h $(srcdir)/c-tree.h $(srcdir)/c-common.h \
$(srcdir)/input.h $(srcdir)/flags.h $(srcdir)/output.h \ $(srcdir)/input.h $(srcdir)/flags.h $(srcdir)/output.h \
$(srcdir)/objc/objc-act.h $(SYSTEM_H) cpplib.h $(srcdir)/objc/objc-act.h $(SYSTEM_H) $(CPPLIB_H)
$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/objc \ $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) -I$(srcdir)/objc \
-c $(srcdir)/objc/objc-parse.c $(OUTPUT_OPTION) -c $(srcdir)/objc/objc-parse.c $(OUTPUT_OPTION)
......
...@@ -111,13 +111,10 @@ scan_decls (pfile, argc, argv) ...@@ -111,13 +111,10 @@ scan_decls (pfile, argc, argv)
brace_nesting++; brace_nesting++;
goto new_statement; goto new_statement;
} }
if (token.type == CPP_EOF) if (token.type == CPP_EOF)
{ return 0;
if (cpp_pop_buffer (pfile) == 0)
return 0;
goto new_statement;
}
if (token.type == CPP_SEMICOLON) if (token.type == CPP_SEMICOLON)
goto new_statement; goto new_statement;
if (token.type != CPP_NAME) if (token.type != CPP_NAME)
...@@ -148,9 +145,7 @@ scan_decls (pfile, argc, argv) ...@@ -148,9 +145,7 @@ scan_decls (pfile, argc, argv)
goto new_statement; goto new_statement;
case CPP_EOF: case CPP_EOF:
if (cpp_pop_buffer (pfile) == 0) return 0;
return 0;
break;
case CPP_OPEN_PAREN: case CPP_OPEN_PAREN:
/* Looks like this is the start of a formal parameter list. */ /* Looks like this is the start of a formal parameter list. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment