diff options
author | thorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-07 03:12:23 +0000 |
---|---|---|
committer | thorpej <thorpej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-04-07 03:12:23 +0000 |
commit | d3f7919d2a630945daba61dc8cf51ed5cde46ed1 (patch) | |
tree | a89c2d17b9489b6bd19288f037013b3eaa28a891 /gcc/cpplib.c | |
parent | a09b9b19f2afb1554c1f642a77147684d467ab8f (diff) | |
download | gcc-d3f7919d2a630945daba61dc8cf51ed5cde46ed1.tar.gz |
* cppinit.c (cpp_create_reader): Initialize
discard_comments_in_macro_exp.
(COMMAND_LINE_OPTIONS): Add "-CC" option.
(cpp_handle_option): Handle "-CC" option.
* cpplex.c (save_comment): If saving a C++ comment in
a directive, convert it to a C comment.
(_cpp_lex_direct): Pass second comment start character to
save_comment to indicate comment type.
* cpplib.c (_cpp_handle_directive): If processing
a "#define" directive and discard_comments_in_macro_exp
is false, re-enable saving of comments.
(lex_macro_node): If discard_comments_in_macro_exp is false,
discard any comments before the macro identifier.
* cpplib.h (struct cpp_options): Add discard_comments_in_macro_exp
member.
* cppmacro.c (cpp_get_token): If expanding a macro while
processing a directive, discard any comments we might encounter.
(parse_params): If discard_comments_in_macro_exp is false,
ignore comments in the macro parameter list.
* gcc.c (cpp_unique_options): Add "-CC" option.
(option_map): Map "--comments-in-macros" to "-CC".
* doc/cppopts.texi: Document "-CC" option.
* f/lang-specs.h: Add "-CC" option.
* testsuite/gcc.dg/cpp/maccom1.c: New test.
* testsuite/gcc.dg/cpp/maccom2.c: New test.
* testsuite/gcc.dg/cpp/maccom3.c: New test.
* testsuite/gcc.dg/cpp/maccom4.c: New test.
* testsuite/gcc.dg/cpp/maccom5.c: New test.
* testsuite/gcc.dg/cpp/maccom6.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@51975 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cpplib.c')
-rw-r--r-- | gcc/cpplib.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/gcc/cpplib.c b/gcc/cpplib.c index 9a6b077f24b..47dd977f305 100644 --- a/gcc/cpplib.c +++ b/gcc/cpplib.c @@ -394,6 +394,13 @@ _cpp_handle_directive (pfile, indented) if (dir) { + /* If we are processing a `#define' directive and we have been + requested to expand comments into macros, then re-enable + saving of comments. */ + if (dir == &dtable[T_DEFINE]) + pfile->state.save_comments = + ! CPP_OPTION (pfile, discard_comments_in_macro_exp); + pfile->directive = dir; (*pfile->directive->handler) (pfile); } @@ -445,7 +452,16 @@ lex_macro_node (pfile) In C++, it may not be any of the "named operators" either, per C++98 [lex.digraph], [lex.key]. Finally, the identifier may not have been poisoned. (In that case - the lexer has issued the error message for us.) */ + the lexer has issued the error message for us.) + + Note that if we're copying comments into macro expansions, we + could encounter comment tokens here, so eat them all up first. */ + + if (! CPP_OPTION (pfile, discard_comments_in_macro_exp)) + { + while (token->type == CPP_COMMENT) + token = _cpp_lex_token (pfile); + } if (token->type != CPP_NAME) { |