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/RFA] Add -CC option to cpplib to save comments in macros


Back to an old topic...

After the last time I proposed this patch, Neil and I hashed out how
this should actually work, and the attached patch is the result of
the discussion we had, updated for the current GCC trunk.

To remind everyone what this is about ... I have added a -CC option
to the preprocessor that is like -C, but also preserves comments in
macros when they're expanded and copied into the output file.  This
is necessary in order to support lint(1).

A simple example input file:

#define MACRO(x) \
do { \
        (x) = (x); \
} while (/*CONSTCOND*/0)

/*ARGSUSED*/
void
foo(int x, int y)
{

        MACRO(x);
}

...when processed with -CC:

frau-farbissina:thorpej 30$ alpha-unknown-netbsd-gcc -E -CC cpptest.c  
# 1 "cpptest.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "cpptest.c"





/*ARGSUSED*/
void
foo(int x, int y)
{

        do { (x) = (x); } while (/*CONSTCOND*/0);
}

Bootstrapped on i386-unknown-netbsd and alpha-unknown-netbsd.

OK to commit?

        * cppinit.c (cpp_create_reader): Initialize
        discard_comments_in_macro_exp.
        (COMMAND_LINE_OPTIONS): Add "-CC" option.
        (cpp_handle_option): Handle "-CC" option.
        * cpplib.c (_cpp_handle_directive): If processing
        a "#define" directive and discard_comments_in_macro_exp 
        is false,  re-enable saving of comments. 
        * 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. 
        * 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.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>

Attachment: cpp-cc.patch
Description: cpp-cc.patch


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