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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Error message is displayed redundantly twice when an invalid optimization level is specified
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Consider the following **invalid** command line.
```console
$ clang -O1-aaa test.c
```

Error message:
```console
error: invalid integral value '1-aaa' in '-O1-aaa'
error: invalid integral value '1-aaa' in '-O1-aaa'
```
https://godbolt.org/z/3hn4cThMK
The message content itself is correct, but it is redundant to appear twice.

I think GCC's error message is much easier to understand.
```console
$ gcc -O1-aaa test.c
cc1: error: argument to ‘-O’ should be a non-negative integer, ‘g’, ‘s’ or ‘fast’
```

FYI. Flang (flang-new) does not have this problem.
```console
$ flang-new -O1-aaa test.f90
error: invalid integral value '1-aaa' in '-O1-aaa'
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVEFvqzgQ_jXmMiIyDgQ4cMimZVWtVr30skdjD-CtsZFtErW__skkTV6j914vlZCxB8_HzDffDPdeDQaxIcVfpHhI-BJG65rXlDtnTz7prHxrDtZ4JdFBGBF6q7U9KTMAYXvC9socuVbyfABhp4kbCVoZ3BD6QOie7Oj5EdZ4q_FiZTkIzc0A6XOWcs4hoA8bcedzOa7ro3PWwYTe8wHJdv8neIx3yXYPl_BAmYCD4xqOXC8IhJXrXwkrQZl4vIRBWPldCHdJjCHMPobNWsLawcrO6rCxbiCsfSes3Y4mFy_jv_-cr7-M-JErCGsCmgAqeNQ9KA_COociEHaAbokfotGhXIzkJkCwwOcZuYNwUuJaiXV9gjAq8wp_Hw6ElR7wZ1ojzLSIEZB7FStuYTESnQ_cyC8LOgjxy3IKkUUmr5RyNywTnuMkj4xUlNRV-vyxrcGPdtESOgQOxprU4MCDOuK5COhi3lfH4er3yexvcNbdzD334ebwe7W1_z1toF0VSljVx01q8ERYDdKiB2MDjPyIkU0Ps7OdxulLhq44n3nqa_rtqktks5X1tuYJNllJ84LV9Y4mY9PTiua7bFcKxJ3sihKLctsjLXaC9VhliWoYZTnN6I5WW5bTTS-7UhQ0y6Wo8lxIklOcuNIbrY9TlHCivF-wKcusKhPNO9R-nSiMrT1OGIvDxTXxftotgyc51coHf0MIKuh1DB1Wj-IBHu-FKZWfNX9DeVO6fjsrHE4jGuDmypudg5rUOw_KGtB4RB0R_IxC9Qplsjjd3HWkCuPSbYSdCGtjWJdXOjv7_9pr7ZqlJ6xdE_0RAAD__1zHlWM">