This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][libcpp] New deferred output pragma


Hi,

This patch adds a new deferred_output pragma to the preprocessor. For
example, this code:

---
#define EMIT_AT_EOF(name,body) void name() {body}

#define EMIT_FUNC(name,body) void name(); name(); EMIT_AT_EOF(name,body)

#pragma GCC deferred_output EMIT_AT_EOF

int main ()
{
  EMIT_FUNC (exit_code, printf("blah\n"););
  
  return 0;
}

Will result in the expansion of the EMIT_AT_EOF macro use being output
at the end of the file.

Tested on i686-pc-linux-gnu. Is it ok?

Thanks,
Dave.

---

libcpp/ChangeLog:

2010-04-01  David Stubbs  <stubbs@icerasemi.com>

	* macro.c (add_token_to_deferred_output_list, replace_args)
	(cpp_get_token): Implemented #pragma deferred_output.
	* lex.c (_cpp_lex_direct): Don't try and read a new line of the
file
	if we're processing deferred_output macros.
	* internal.h (struct def_output_pragma, struct cpp_reader):
Added 
	deferred_output token list.
	* init.c (cpp_create_reader, cpp_destroy): Initialize / destroy
	deferred_output.
	* include/cpplib.h (NODE_DEF_OUTPUT, struct cpp_hashnode): New
field to 
	keep track of deferred_output macros.
	* directives.c (_cpp_init_internal_pragmas): Added
deferred_output
	pragma.
	(do_pragma_deferred_output): New function.

gcc/ChangeLog:

2010-04-01  David Stubbs  <stubbs@icerasemi.com>

	* doc/cpp.texi (Pragmas): Document deferred_output pragma.

gcc/testsuite/ChangeLog:

2010-04-01  David Stubbs  <stubbs@icerasemi.com>

	* gcc.dg/cpp/defout-pragma.c: New deferred_output pragma test.

Attachment: deferred_output_pragma.patch
Description: deferred_output_pragma.patch


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]