svn commit: r257203 - head/sys/arm/arm

Jilles Tjoelker jilles at stack.nl
Sun Oct 27 22:08:02 UTC 2013


On Mon, Oct 28, 2013 at 08:43:37AM +1100, Bruce Evans wrote:
> On Sun, 27 Oct 2013, Ian Lepore wrote:

> >On Mon, 2013-10-28 at 04:42 +1100, Bruce Evans wrote:
> >>On Sun, 27 Oct 2013, Ian Lepore wrote:
> >>
> >>>Log:
> >>> Eliminate a compiler warning about extraneous parens.
> >>
> >>Wow, what flags give these warnings?

> >--- busdma_machdep.o ---
> >/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
> >       if ((map->pagesneeded == 0)) {
> >            ~~~~~~~~~~~~~~~~~^~~~

> Ahh.  I guess what I really want is -Wredundant-parentheses
> -Wredundant-braces ...  The parser can easily tell what is redundant
> than what is bogus since bogusness depends on style and too many
> suboptions would be required to specify styles
> (-Wparentheses[-operator][-context].

> Oops, the parser easily can't do this right because macro parameters
> must usually have redundant parentheses and C parsers are specified
> to act as if on the output of the preprocessor so they can't easily
> either have a special case to ignore these redundant parentheses or
> know that they aren't in the unpreprocessed source so they should be
> ignored.

> >/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24: note: remove extraneous parentheses around the comparison to silence this warning
> >       if ((map->pagesneeded == 0)) {
> >           ~                 ^   ~
> >/local/build/staging/freebsd/dp10/src/sys/arm/arm/busdma_machdep.c:811:24: note: use '=' to turn this equality comparison into an assignment
> >       if ((map->pagesneeded == 0)) {
> >                             ^~
> >                             =

> >That's what the compiler had to say about it.  I guess in somebody's
> >mind if it's a probable error to have done
> >...

> This expression could be the result of a macro

> #define	ISZERO(x)	((x) == 0)

> which for if (ISZERO(map->pagesneeded)) expands to almost the above.  I
> guess clang warns excessively about this.

Clang takes advantage of its internal preprocessor to suppress certain
warnings in results of macro expansion. In fact, this is what makes
-Wparentheses-equality possible at all. It does not violate the C
standard, since it is only used to decide whether to issue certain
warnings and does not affect the semantics of the code.

This check breaks down when the internal preprocessor is not used, such
as with ccache.

-- 
Jilles Tjoelker


More information about the svn-src-head mailing list