Commit a8d0ddaf by Zack Weinberg

cpphash.h (struct lexer_state): Add directive_wants_padding.

	* cpphash.h (struct lexer_state): Add directive_wants_padding.
	* cpplib.c (_cpp_handle_directive): Set directive_wants_padding
	for directives of type INCL.
	(glue_header_name, parse_include): Use get_token_no_padding.
	* cppmacro.c (replace_args): If directive_wants_padding,
	provide padding tokens.

	* testsuite/gcc.dg/cpp/include3.c: New test.
	* testsuite/gcc.dg/cpp/inc/foo.h: New file.

From-SVN: r63231
parent 3a3f137e
2003-02-21 Zack Weinberg <zack@codesourcery.com>
* cpphash.h (struct lexer_state): Add directive_wants_padding.
* cpplib.c (_cpp_handle_directive): Set directive_wants_padding
for directives of type INCL.
(glue_header_name, parse_include): Use get_token_no_padding.
* cppmacro.c (replace_args): If directive_wants_padding,
provide padding tokens.
2003-02-21 Kazu Hirata <kazu@cs.umass.edu> 2003-02-21 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300.md (a peephole2): New. * config/h8300/h8300.md (a peephole2): New.
......
...@@ -214,6 +214,11 @@ struct lexer_state ...@@ -214,6 +214,11 @@ struct lexer_state
/* Nonzero if first token on line is CPP_HASH. */ /* Nonzero if first token on line is CPP_HASH. */
unsigned char in_directive; unsigned char in_directive;
/* Nonzero if in a directive that will handle padding tokens itself.
#include needs this to avoid problems with computed include and
spacing between tokens. */
unsigned char directive_wants_padding;
/* True if we are skipping a failed conditional group. */ /* True if we are skipping a failed conditional group. */
unsigned char skipping; unsigned char skipping;
......
...@@ -414,6 +414,7 @@ _cpp_handle_directive (pfile, indented) ...@@ -414,6 +414,7 @@ _cpp_handle_directive (pfile, indented)
skipping or not, we should lex angle-bracketed headers skipping or not, we should lex angle-bracketed headers
correctly, and maybe output some diagnostics. */ correctly, and maybe output some diagnostics. */
pfile->state.angled_headers = dir->flags & INCL; pfile->state.angled_headers = dir->flags & INCL;
pfile->state.directive_wants_padding = dir->flags & INCL;
if (! CPP_OPTION (pfile, preprocessed)) if (! CPP_OPTION (pfile, preprocessed))
directive_diagnostics (pfile, dir, indented); directive_diagnostics (pfile, dir, indented);
if (pfile->state.skipping && !(dir->flags & COND)) if (pfile->state.skipping && !(dir->flags & COND))
...@@ -582,7 +583,7 @@ glue_header_name (pfile) ...@@ -582,7 +583,7 @@ glue_header_name (pfile)
buffer = (unsigned char *) xmalloc (capacity); buffer = (unsigned char *) xmalloc (capacity);
for (;;) for (;;)
{ {
token = cpp_get_token (pfile); token = get_token_no_padding (pfile);
if (token->type == CPP_GREATER || token->type == CPP_EOF) if (token->type == CPP_GREATER || token->type == CPP_EOF)
break; break;
...@@ -634,7 +635,7 @@ parse_include (pfile) ...@@ -634,7 +635,7 @@ parse_include (pfile)
dir = pfile->directive->name; dir = pfile->directive->name;
/* Allow macro expansion. */ /* Allow macro expansion. */
header = cpp_get_token (pfile); header = get_token_no_padding (pfile);
if (header->type != CPP_STRING && header->type != CPP_HEADER_NAME) if (header->type != CPP_STRING && header->type != CPP_HEADER_NAME)
{ {
if (header->type != CPP_LESS) if (header->type != CPP_LESS)
......
...@@ -899,7 +899,7 @@ replace_args (pfile, node, macro, args) ...@@ -899,7 +899,7 @@ replace_args (pfile, node, macro, args)
count = arg->expanded_count, from = arg->expanded; count = arg->expanded_count, from = arg->expanded;
/* Padding on the left of an argument (unless RHS of ##). */ /* Padding on the left of an argument (unless RHS of ##). */
if (!pfile->state.in_directive if ((!pfile->state.in_directive || pfile->state.directive_wants_padding)
&& src != macro->exp.tokens && !(src[-1].flags & PASTE_LEFT)) && src != macro->exp.tokens && !(src[-1].flags & PASTE_LEFT))
*dest++ = padding_token (pfile, src); *dest++ = padding_token (pfile, src);
......
2003-02-21 Zack Weinberg <zack@codesourcery.com>
* gcc.dg/cpp/include3.c: New test.
* gcc.dg/cpp/inc/foo.h: New file.
2003-02-21 Glen Nakamura <glen@imodulo.com> 2003-02-21 Glen Nakamura <glen@imodulo.com>
* gcc.c-torture/execute/20030221-1.c: New test. * gcc.c-torture/execute/20030221-1.c: New test.
......
/* Unpatched, this file would include "inc/ foo.h" (note the space) */
#define PREINC_XSTR(str) #str
#define PREINC_STR(str) PREINC_XSTR(str)
#define COMP_INC(comp,file) PREINC_STR(comp/file)
#include COMP_INC(inc, foo.h)
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