https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82710

            Bug ID: 82710
           Summary: Incorrect warning:unnecessary parentheses in
                    declaration of global friend functions
                    [-Werror=parentheses]
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andi at mozilla dot com
  Target Milestone: ---

Created attachment 42466
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42466&action=edit
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

Reply via email to