Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

glibc 2.20 WIFCONTINUED raises a -Wparentheses-equality warning #22948

Open Quuxplusone opened 9 years ago

Quuxplusone commented 9 years ago
Bugzilla Link PR22949
Status NEW
Importance P normal
Reported by Lubomir Rintel (lkundrak@v3.sk)
Reported on 2015-03-18 11:32:44 -0700
Last modified on 2015-03-18 11:40:15 -0700
Version 3.5
Hardware PC Linux
CC dblaikie@gmail.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
It complains about extra parentheses around comparison, however no such thing
exists in the source -- the warning concerns the expanded macros:

[lkundrak@belphegor NetworkManager]$ clang -Werror -Wparentheses-equality -Wno-
unused -c feh.c
feh.c:2:99: error: equality comparison with extraneous parentheses [-Werror,-
Wparentheses-equality]
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
feh.c:2:99: note: remove extraneous parentheses around the comparison to
silence this warning
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                ~                                                                                 ^        ~
feh.c:2:99: note: use '=' to turn this equality comparison into an assignment
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                                                                                                  ^~
                                                                                                  =
1 error generated.
[lkundrak@belphegor NetworkManager]$ cat feh.c
#include <sys/wait.h>
void f () { if (WIFCONTINUED(0)) return; }
[lkundrak@belphegor NetworkManager]$
Quuxplusone commented 9 years ago
This doesn't look like the output of clang (clang's diagnostics quote the
original source, not the post-processed source). Did you run this through the
preprocessor manually before giving it to clang?

Not sure how else you'd get that output...

(could you provide a standalone reproduction?)

I don't get a missing-prototype warning for the original source code you gave:

$ cat tmp.c
#include <sys/wait.h>
void f () { if (WIFCONTINUED(0)) return; }
$ clang-tot -Weverything -c tmp.c
tmp.c:2:6: warning: no previous prototype for function 'f' [-Wmissing-
prototypes]
void f () { if (WIFCONTINUED(0)) return; }
     ^
1 warning generated.
Quuxplusone commented 9 years ago
If you use --save-temps, then you get the behavior you reported - perhaps
that's what you're doing?

$ clang-tot --save-temps -Weverything -c tmp.c
tmp.c:2:99: warning: equality comparison with extraneous parentheses [-
Wparentheses-equality]
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
tmp.c:2:99: note: remove extraneous parentheses around the comparison to
silence this warning
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                ~                                                                                 ^        ~
tmp.c:2:99: note: use '=' to turn this equality comparison into an assignment
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
                                                                                                  ^~
                                                                                                  =
tmp.c:2:6: warning: no previous prototype for function 'f' [-Wmissing-
prototypes]
void f () { if ((((__extension__ (((union { __typeof(0) __in; int __i; }) {
.__in = (0) }).__i))) == 0xffff)) return; }
     ^
2 warnings generated.

I believe --save-temps is only intended as a debugging aid & doesn't guarantee
diagnostic consistency with the usual compile command line? But I'm not
entirely sure. Perhaps we don't have an official stance on this...