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


Folks...

The following patch adds a -CC option to the pre-processor which
is like -C (save comments), but also copies comments to the output
where macros are expanded.  This is primarily to support lint.

To illustrate the difference in behavior:

  -- test.c --
/* outside macro */            
#define TEST do { /* inside macro */ a = 0; } while (/*CONSTCOND*/0)

void
test()
{
        int a;

        TEST;
}
  -- end of test.c --

dr-evil:thorpej 194$ i386-unknown-netbsdelf-gcc -E test.c         
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"



void
test()
{
        int a;

        do { a = 0; } while ( 0);
}
dr-evil:thorpej 195$ i386-unknown-netbsdelf-gcc -E -Wp,-C test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
/* outside macro */


void
test()
{
        int a;

        do { a = 0; } while ( 0);
}
dr-evil:thorpej 196$ i386-unknown-netbsdelf-gcc -E -Wp,-CC test.c
# 1 "test.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "test.c"
/* outside macro */


void
test()
{
        int a;

        do { /* inside macro */ a = 0; } while (/*CONSTCOND*/0);
}
dr-evil:thorpej 197$ 


	[ for gcc/ChangeLog ]
2002-01-02  Jason Thorpe  <thorpej@wasabisystems.com>

	* 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.
	* doc/cpp.texi: Document the -CC option.

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

Attachment: JRT-patch3
Description: patch3


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