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]

Re: -fpreprocessed, directives, #line and other fun


Zack Weinberg wrote:-

> We really shouldn't allow any directives with -fpreprocessed.  The
> reason we accept #define now is so that if you write -g3 -save-temps,
> the compiler's callback for the #define will still get run.

Are you saying we should accept #define (and by implication #undef),
and no others?  We don't generate the callbacks for command line
options...

If we do, what about avoiding macro expansions?  Either we can check
for fpreprocessed on each expansion (a performance hit), or we can not
insert the macro in the hash tables.

> This is difficult to get 100% right.  If I write
> 
> #define HASH #
> 
> HASH define foo bar
> 
> foo
> 
> with -g3 -save-temps, the temp file will contain
> 
> #define HASH #
> 
> # define foo bar
> 
> foo
> 
> -- and the compiler's callback ought to be run for #define HASH, but
> the "# define foo bar" line should be passed through as ordinary
> text.

If we want to bother to get this right too (I don't mind either way),
we could check for lack of a space before the "define".  It's a kludge
but it would work provided we ensure cppmain.c doesn't insert one,
which it doesn't at present.

Neil.

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