Created attachment 42466 [details] test case to reproduce the warning When trying to build the mozilla-central repo with treat warnings as errors I get this error: In file included from /root/firefox-gcc-last/image/SVGDocumentWrapper.cpp:27:0, from /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/image/Unified_cpp_image1.cpp:38: /root/firefox-gcc-last/obj-x86_64-pc-linux-gnu/dist/include/mozilla/dom/SVGSVGElement.h:85:19: error: unnecessary parentheses in declaration of 'NS_NewSVGSVGElement' [-Werror=parentheses] friend nsresult (::NS_NewSVGSVGElement(nsIContent **aResult, The code can be found here: https://dxr.mozilla.org/mozilla-central/source/dom/svg/SVGSVGElement.h#85 I consider this to be a bug since the resolution operator is used in order to point the global function NS_NewSVGSVGElement that is not in the mozilla::dom namespace. In order to be more easely debuged I've created test case, that is attached to this bug. For my test case I got the same warning: >>In file included from main.cpp:1:0: >>def.h:13:20: error: unnecessary parentheses in declaration of 'friendFunc' [->>Werror=parentheses] >> friend TestClass (::friendFunc()); The way how I build it is: # g++-8 -Wall -Werror main.cpp
With gcc-8 (Debian 8-20171023-1) 8.0.0 20171023 (experimental) [trunk revision 253997]
I think this warning was intentionally added. Splitting to some other warning option might be possible though.
Richard is correct, and I picked the existing Wparenthesis warning to enable it. However, I think this is a false positive as Andi states.
Self-contained testcase (rather than a zip file with several files in, which https://gcc.gnu.org/bugs/ says we don't want): class X; X friendFunc(); namespace nm { class TestClass { friend X (::friendFunc()); }; }
Author: nathan Date: Thu Nov 2 18:26:29 2017 New Revision: 254349 URL: https://gcc.gnu.org/viewcvs?rev=254349&root=gcc&view=rev Log: [PR c++/82710] false positive paren warning https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00119.html PR c++/82710 * decl.c (grokdeclarator): Don't warn when parens protect a return type from a qualified name. PR c++/82710 * g++.dg/warn/pr82710.C: New. Added: trunk/gcc/testsuite/g++.dg/warn/pr82710.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog
Fixed r254349.
Author: nathan Date: Fri Nov 3 13:16:06 2017 New Revision: 254371 URL: https://gcc.gnu.org/viewcvs?rev=254371&root=gcc&view=rev Log: [PR c++/82710] false positive paren warning https://gcc.gnu.org/ml/gcc-patches/2017-11/msg00186.html PR c++/82710 * decl.c (grokdeclarator): Protect MAYBE_CLASS things from paren warning too. PR c++/82710 * g++.dg/warn/pr82710.C: More cases. Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/g++.dg/warn/pr82710.C