This is the mail archive of the gcc@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]

Re: Add new CPP arithmetic warning?


Zack Weinberg wrote:-

> Would you mind splitting it up?  Do the rework, apply that, then send
> in the patch to add the warning, which might conceivably be
> controversial.

Here's an interesting question.  Do we want to warn in this case
(EDG does, my initial patch doesn't).

#if 1 ? 0U : -1
#endif

To be able to warn in this case, CPP has to evaluate the 3rd argument
of ?: ; note that in this case it has an operator.

The way we have CPP written, it doesn't evaluate the 3rd argument at
all, if the 1st argument is true, which saves a few microseconds and
avoids emitting warnings.

If we want to get the warning even in the above case, we need to
evaluate the expression, but to suppress any diagnostics caused by
evaluating the expression.  There are only 3 such diagnostics:

1) a pedwarn about ','
2) a division by zero diagnostic
3) trad C rejects unary '+'

Pushing the if (pfile->state.skip_eval) down to these areas rather than
keeping it higher up would be trivial.

What do you think?

Neil.


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