<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55897>55897</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clang diagnostic group command line behavior difference from GCC
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            enhancement,
            clang:driver,
            clang:frontend,
            clang:diagnostics
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          AaronBallman
      </td>
    </tr>
</table>

<pre>
    As was observed in #55492, GCC handles diagnostic groupings differently on the command line than Clang does. For warning groups, GCC documents the [following](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html): "The combined effect of positive and negative forms is that more specific options have priority over less specific ones, independently of their position in the command-line.". From my testing, it seems this behavior started in GCC 4.8.1. However, the same behavior is not implemented in Clang, which takes a last-flag-wins approach.

I don't see any evidence that we intended to have a different behavior here from GCC, but it's also not really clear that this is a bug either. I think we probably should match the GCC diagnostic behavior and so I think this is a reasonable enhancement request.

As an immediate workaround, users can put the more specific flags at the end of the command line rather than at the beginning. Then it will work the same in both Clang and GCC.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxtVMtu2zAQ_Br5srBgy08ddHAcpM2plwI9U9RKYkORKknZyN93SDlxHRQQJPCxuzOzs6pt816dPF2FJ1t7dhduSBnKis1uty2LrDjTt_OZemEazZ4aJTpjfVCSOmenUZkubrYtOzZBv5M1FHomaYcBIaSVYWwIQ2ctTEeNZZ_Ti3Wo6Ayi5zT-o05j5TQgk09Zst1Ta7W2V1zMds9ZcexDwOXNKSte8HRS5p2Zcus6rKyJ1ZDBz0d4_5qLLH-MQVnj8z4MOitKJADD4ucMtI5RxOAgA9mWRutVUBemSMBwJ9KitW7wpCIwEWiwjsmPLFULKeycHirh4uiUdSpAigs7gmj-n4uGE1VlGh4Zr1mzNrJV7lYZEqoHFZeRVw7AUM7ZgYZ3Cowe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