From 477cdac7549280eaf6d79ab9dce15e0099e01ce0 Mon Sep 17 00:00:00 2001 From: Jason Thorpe Date: Sun, 7 Apr 2002 03:12:23 +0000 Subject: cppinit.c (cpp_create_reader): Initialize discard_comments_in_macro_exp. * 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. From-SVN: r51975 --- gcc/cppmacro.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'gcc/cppmacro.c') diff --git a/gcc/cppmacro.c b/gcc/cppmacro.c index a022581..6ba7ec4 100644 --- a/gcc/cppmacro.c +++ b/gcc/cppmacro.c @@ -1015,6 +1015,9 @@ cpp_get_token (pfile) return &pfile->avoid_paste; } + if (pfile->state.in_directive && result->type == CPP_COMMENT) + continue; + if (result->type != CPP_NAME) break; @@ -1194,6 +1197,12 @@ parse_params (pfile, macro) switch (token->type) { default: + /* Allow/ignore comments in parameter lists if we are + preserving comments in macro expansions. */ + if (token->type == CPP_COMMENT + && ! CPP_OPTION (pfile, discard_comments_in_macro_exp)) + continue; + cpp_error (pfile, "\"%s\" may not appear in macro parameter list", cpp_token_as_text (pfile, token)); return 0; -- cgit v1.1