diff options
author | Neil Booth <neil@daikokuya.demon.co.uk> | 2001-03-03 22:14:08 +0000 |
---|---|---|
committer | Neil Booth <neil@gcc.gnu.org> | 2001-03-03 22:14:08 +0000 |
commit | e8408f251a70640dcc208877ef3122efd5b7e824 (patch) | |
tree | 7dc28de2225965477d01df8a6de99ec5755e2829 /gcc/cpplex.c | |
parent | 20f9202d81c1a89a0cb65a6ef260101a8ee8822b (diff) | |
download | gcc-e8408f251a70640dcc208877ef3122efd5b7e824.zip gcc-e8408f251a70640dcc208877ef3122efd5b7e824.tar.gz gcc-e8408f251a70640dcc208877ef3122efd5b7e824.tar.bz2 |
cpplex.c (_cpp_lex_token): Don't warn about directives in macro arguments when looking for the '('.
* cpplex.c (_cpp_lex_token): Don't warn about directives in
macro arguments when looking for the '('.
* cppmacro.c (funlike_invocation_p): Set parsing_args to
2 when really parsing arguments; 1 when looking for '('.
Always restore the lexer position.
* gcc.dg/cpp/cppmacro7.c: New test.
From-SVN: r40223
Diffstat (limited to 'gcc/cpplex.c')
-rw-r--r-- | gcc/cpplex.c | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/gcc/cpplex.c b/gcc/cpplex.c index 939951a..bd96303 100644 --- a/gcc/cpplex.c +++ b/gcc/cpplex.c @@ -1171,38 +1171,36 @@ _cpp_lex_token (pfile, result) result->type = CPP_HASH; do_hash: - if (bol) + if (!bol) + break; + /* 6.10.3 paragraph 11: If there are sequences of preprocessing + tokens within the list of arguments that would otherwise act + as preprocessing directives, the behavior is undefined. + + This implementation will report a hard error, terminate the + macro invocation, and proceed to process the directive. */ + if (pfile->state.parsing_args) { - if (pfile->state.parsing_args) - { - /* 6.10.3 paragraph 11: If there are sequences of - preprocessing tokens within the list of arguments that - would otherwise act as preprocessing directives, the - behavior is undefined. - - This implementation will report a hard error, terminate - the macro invocation, and proceed to process the - directive. */ - cpp_error (pfile, - "directives may not be used inside a macro argument"); - - /* Put a '#' in lookahead, return CPP_EOF for parse_arg. */ - buffer->extra_char = buffer->read_ahead; - buffer->read_ahead = '#'; - pfile->state.next_bol = 1; - result->type = CPP_EOF; - - /* Get whitespace right - newline_in_args sets it. */ - if (pfile->lexer_pos.col == 1) - result->flags &= ~(PREV_WHITE | AVOID_LPASTE); - } - else - { - /* This is the hash introducing a directive. */ - if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE)) - goto done_directive; /* bol still 1. */ - /* This is in fact an assembler #. */ - } + if (pfile->state.parsing_args == 2) + cpp_error (pfile, + "directives may not be used inside a macro argument"); + + /* Put a '#' in lookahead, return CPP_EOF for parse_arg. */ + buffer->extra_char = buffer->read_ahead; + buffer->read_ahead = '#'; + pfile->state.next_bol = 1; + result->type = CPP_EOF; + + /* Get whitespace right - newline_in_args sets it. */ + if (pfile->lexer_pos.col == 1) + result->flags &= ~(PREV_WHITE | AVOID_LPASTE); + } + else + { + /* This is the hash introducing a directive. */ + if (_cpp_handle_directive (pfile, result->flags & PREV_WHITE)) + goto done_directive; /* bol still 1. */ + /* This is in fact an assembler #. */ } break; |