LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 22949 - glibc 2.20 WIFCONTINUED raises a -Wparentheses-equality warning
Summary: glibc 2.20 WIFCONTINUED raises a -Wparentheses-equality warning
Status: NEW
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: 3.5
Hardware: PC Linux
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-18 11:32 PDT by Lubomir Rintel
Modified: 2015-03-18 11:40 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lubomir Rintel 2015-03-18 11:32:44 PDT
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]$
Comment 1 David Blaikie 2015-03-18 11:38:37 PDT
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.
Comment 2 David Blaikie 2015-03-18 11:40:15 PDT
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...