This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/70065] Split -Wparentheses warnings about operators priority into a separate warning flag, -Wprecedence


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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-09-28
                 CC|                            |egallager at gcc dot gnu.org
            Summary|Add a new option to         |Split -Wparentheses
                   |suppress a warnings about   |warnings about operators
                   |operators priority          |priority into a separate
                   |                            |warning flag, -Wprecedence
     Ever confirmed|0                           |1

--- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> ---
My old version of clang puts this under -Wlogical-op-parentheses:

$ cat 70065.cc
bool a, b, c;

// Something...
int main()
{
        if (a && b || c)
        {
                // Do something...
        }
}
$ /usr/local/bin/g++ -c -Wall -Wextra -pedantic 70065.cc
70065.cc: In function ‘int main()’:
70065.cc:6:8: warning: suggest parentheses around ‘&&’ within ‘||’
[-Wparentheses]
  if (a && b || c)
      ~~^~~~
$ /sw/opt/llvm-3.1/bin/clang -c -Wall -Wextra -pedantic 70065.cc
70065.cc:6:8: warning: '&&' within '||' [-Wlogical-op-parentheses]
        if (a && b || c)
            ~~^~~~ ~~
70065.cc:6:8: note: place parentheses around the '&&' expression to silence
this warning
        if (a && b || c)
              ^
            (     ) 
1 warning generated.
$

So confirming that another compiler has another name for it, regardless of
bikeshedding about the specific name to give it.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]