Lack of control over diagnostics related to parentheses

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: Low

      Build the attached source file ...

      % tiarmclang -c file.c
      file.c:4:14: warning: & has lower precedence than !=; != will be evaluated first [-Wparentheses]
          4 |     if (arg1 & 0x1u != 0)
            |              ^~~~~~~~~~~
      file.c:4:14: note: place parentheses around the '!=' expression to silence this warning
          4 |     if (arg1 & 0x1u != 0)
            |              ^
            |                (        )
      file.c:4:14: note: place parentheses around the & expression to evaluate it first
          4 |     if (arg1 & 0x1u != 0)
            |              ^
            |         (          )
      file.c:13:15: warning: equality comparison with extraneous parentheses [-Wparentheses-equality]
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |          ~~~~~^~~~~~~
      file.c:13:15: note: remove extraneous parentheses around the comparison to silence this warning
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |         ~     ^      ~
      file.c:13:15: note: use '=' to turn this equality comparison into an assignment
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |               ^~
            |               =
      

      The user wants to change the handling of the first diagnostic to an error, while continuing to handle the second diagnostic as a warning. There appears to be no method for doing that. For example:

      % tiarmclang -c -Werror=parentheses -Wparentheses-equality file.c
      file.c:4:14: error: & has lower precedence than !=; != will be evaluated first
            [-Werror,-Wparentheses]
          4 |     if (arg1 & 0x1u != 0)
            |              ^~~~~~~~~~~
      file.c:4:14: note: place parentheses around the '!=' expression to silence this warning
          4 |     if (arg1 & 0x1u != 0)
            |              ^
            |                (        )
      file.c:4:14: note: place parentheses around the & expression to evaluate it first
          4 |     if (arg1 & 0x1u != 0)
            |              ^
            |         (          )
      file.c:13:15: error: equality comparison with extraneous parentheses
            [-Werror,-Wparentheses-equality]
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |          ~~~~~^~~~~~~
      file.c:13:15: note: remove extraneous parentheses around the comparison to silence this warning
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |         ~     ^      ~
      file.c:13:15: note: use '=' to turn this equality comparison into an assignment
         13 |     if ((arg1 == 0x2u) /* || (arg1 = 0x3u) */ )
            |               ^~
            |               =
      

      Now both diagnostics are handled as an error.

      The problem is the diagnostic category -Wparentheses serves multiple purposes. It is both an umbrella category that includes other categories like -Wparentheses-equality, as well as a category on its own.

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-5135 - Lack of control over diagnostics re...
                SYNCHRONIZED
                • Last Sync Date: