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

    <tr>
        <th>Summary</th>
        <td>
            Confusing diagnostics: error: 'extern' variable cannot have an initializer
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    This code:
```
static int x;

void f(void)
{
    extern int x = 1;
}
```
leads to:
```
error: 'extern' variable cannot have an initializer
```
which is confusing, because 'extern' variable CAN have an initializer, which is demonstrated by the C standard (C11, 6.9.2 External object definitions, 4, EXAMPLE 1):
```
extern int i3 = 3; // definition, external linkage
```
The expected diagnostics is:
```
error: declaration of block scope identifier x with internal linkage shall have no initializer
```
Relevant quote from C11:
> If the declaration of an identifier has block scope, and the identifier has external or internal linkage, the declaration shall have no initializer for the identifier.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJydU01v2zAM_TX2hVhgS3EcH3xIkxQYsA3D0MOutEXHWhUrk-S03a8frX6k7RIUmCHYEkS-9_hIN1Y91De99tBaRYlcJdkmyVbJInta8egDBt2CHgLcJ_LqKSa-j1Yr6BKxnDaJqJ7uyqcg4IfuA7nhMRsSuYH8hFFuzhIaQuUh2EuCyDnr-BISUT7C8waO6DQ2hqDFYbABejwS4MSsg0aj_5A7i3bX67aH6MHQjV4Pu0SsoaEWR08XKNarb2fxOfEFTtHeDj44DKSgeYDQcx6wmYNCpxh4uc7zKWMxq2YCtpEFDdjmF7WB07uIzBhT0Hx6bX-uvn7_smUL2epL5pz81jIaLtlwprvm9Qp1wqNnTqOHW9zRWcAb1k33B9bEdSiNu8F6ngfPNX7YIEWtQXaA-cB20Bjb3oJv7YFAKxqC7jQ5nos7HfpJ8hs14Hs05tHnwX7Yxx9k6Ihc9u_RBoLO2T1MDr9olFv43MU2vJM1NfGkpkf_WujkE7cs5r2LerHPun_ET2nvqS7WAx0jvCWYpVTni0VeFUKIPFW1VJWsMA06GKrXz6P6uiGT4f_9a6SjM3UfwiE2NQ7LjpsyNrPW7vlgzPH58-ng7DSifNTej8TzeV2U83KZ9rXErmzKUrWVLFGqeYZt0RRNVSyWeUWIqcGGjK-T4ioRYqA7iBC8T4pNqmuRCZEtZZ5LIef5bCm7rO0aLBdV03aiSOYZ7VGb2aRjZt0udXWU1Iw7z5dG--BPl-i93g1EkY7xcQy9dfVhb10u08hcR-V_ASp9lWo">