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

    <tr>
        <th>Summary</th>
        <td>
            `#pragma diagnostic` can't enable a warning that isn't enabled in CLI arguments
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

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

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

<pre>
    Consider the following example from [GCC documentation](https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Diagnostic-Pragmas.html):
```cpp
extern int foo(int);

static void f() {
  int a, b, c, d;
#pragma GCC diagnostic error "-Wuninitialized"
  foo(a);                       /* error is given for this one */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wuninitialized"
  foo(b);                       /* no diagnostic for this one */
#pragma GCC diagnostic pop
  foo(c); /* error is given for this one */
#pragma GCC diagnostic pop
  foo(d);                       /* depends on command-line options */
}
```
GCC issues diagnostics about uninitialized variable even if `-Wno-uninitialized` is passed, while Clang does not: https://godbolt.org/z/bdTWPG3MK . Clang seems to ignore diagnostic pragmas that change severity, unless diagnostic is enabled via CLI arguments.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVMGOpDYQ_RpzKTUyBhr6wKGnO72Kkkh7iDRngwtwZFzINj27-_WRgcxMj6JkFAUhI2NX1Xuvni2914NFbFj5xMprIpcwkmt-skobY5KW1PfmQtZrhQ7CiNCTMfSi7QD4TU6zQegdTcDKpy-XCyjqlgltkEGTZeWViXoMYfYsPzNxY-I2dF062CUlNzBxI2u0RUWd35YOWZ5mKd8mTNyuWg6WfNDd4auTwyR9OobJMHGKCfmV8TM78u3t5nn7g98COgvaBuiJmKi1DWvE0x6xjj5i7OBOWkHPRM3ECVi1b4E1WjJxgTYOXRzUWwaRzyscWDm_ggR0jhwwIQ7Pi9VWBy2N_oGKCfFX4g2S3ADB3z-rVOc9m_Yw6Dta6Cl2QHsgi8DEKug_w5kXP_7LFj1Ycqg-g7n9DGZL77P_B8g0P1bt9qr_myYfC6jP0FI4o1WxDHQ0TdKqQ3Qu0ByN7h9LV9cP1tymEYj2fkH_Do8H2dIS4EF6uEunZWsQMJLUPbAjPzxbOjx26MijErP0PrbrAi-jNggXI-0AitCDpcDyM3w4gqRaMmE_gj-YuLXq9-evX_LffoF0j_aIk4dAuz8eBNwOIoRRBuhGaQcEj3d0OnyPIBZr0PsHj3lAG-kouGsJl19_BumG9Z7waaKaXJ3yk0ywySpeFnVR5lUyNoWs8XiqCt5y3tc8x7wXrSzrWmRHUXBMdCO4KHiWVfxUiKxK66w_nbAQZYtZlpcVKzhOUpvUmPsU6Sar_E1VF1mdGNmi8eu9J0QXWbP83DuyAe1q_vKauCaGHtpl8KzgRvvg35IFHQw2sb2vXnsjHXvTSctEFXbyIOFFOhtvzlU67d-vKtD2UZlkcab50DkdxqVNO5qYuEUc--cwO_oDu8DEbTMYE7eV5J8BAAD___iJzxY">