This is the mail archive of the gcc-bugs@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: Serious error-causing change in new CPP's -traditional behavior


On Fri, May 05, 2000 at 01:14:35PM -0700, Jason R Thorpe wrote:
> On Fri, May 05, 2000 at 12:34:56PM -0700, Zack Weinberg wrote:
> 
>  > I agree this is a bug.  The macro expander is being overhauled right
>  > now, and we don't test -traditional mode much.  Could you try to come
>  > up with a test case in C, not assembly?  Then it can be put into the
>  > test suite.
> 
> I would be happy to.  It is appended at the end of this message.

Thanks, I've added it.

You might try converting whichever file this is to ANSI macro syntax.
Support for preprocessing assembly language in nontraditional mode has
been improved a lot recently.

> While I'm here, I actually have another CPP problem which I haven't
> brought to the attention of the list yet.  It has to do with support
> for lint(1).  In NetBSD, we added a -CC option to cccp, which is
> described as:
> 
>        -C     Do not discard comments: pass them through  to  the
>               output  file.  Comments appearing in arguments of a
>               macro call will be copied to the output before  the
>               expansion of the macro call.
> 
>        -CC    In  addition  to not discarding comments, make sure
>               that a comment that is part  of  the  body  of  the
>               macro  definition, gets expanded in the location of
>               the macro expansion. This  is  useful  for  lint(1)
>               comments.
> 
> This is necessary for thing like:
> 
> #define FOO do { statement1; statement2; } while (/*CONSTCOND*/0)
> 
> Christos Zoulas made the changes, and I thought he fed them back to
> Cygnus/FSF, but if cccp was being replaced with cpplib, I guess it's
> possible that they either fell through the cracks, were rejected, or
> Christos simply forgot to send them.

Hmm.

Right now, comments in a #define line are silently discarded
irrespective of -C, and I'm not sure what happens to comments in the
arguments of a macro (probably the same thing).  I've never heard of
-CC before, but I'd be inclined to make that the behavior of -C.  What
does your -C do with comments in the macro definition?

There used to be commented-out support for recognizing lint comments
and transforming them into #pragmas - the above would become (using
the C99 _Pragma notation)

#define FOO do { statement1; statement2; } while (_Pragma("lint CONSTCOND")0)

It was commented out because no one ever made use of the transformed
annotations, and because we didn't know the real syntax of a lint
comment (it had a finite list of switches it recognized).  Would that
be more useful to your lint?  It could then use cpp's comment
stripper, too.

zw

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