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

    <tr>
        <th>Summary</th>
        <td>
            clang rejects reusing names in unexported variables between modules
        </td>
    </tr>

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

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

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

<pre>
    Given the following three translation units:

```c++
export module a;

constexpr int x = 0;

export void a() {
        (void)x;
}
```

```c++
export module b;

constexpr int x = 0;

export void b() {
        (void)x;
}
```

```c++
import a;
import b;
```

And compiling with

```shell
clang++ -std=c++23 -x c++-module -fmodule-output=a.pcm --precompile -c a.cpp
clang++ -std=c++23 -x c++-module -fmodule-output=b.pcm --precompile -c b.cpp
clang++ -std=c++23 -fmodule-file=a=a.pcm -fmodule-file=b=b.pcm -c c.cpp
```

causes clang to fail with

```console
In file included from c.cpp:1:
a.cpp:3:15: error: declaration 'x' attached to named module 'a' can't be attached to other modules
    3 | constexpr int x = 0;
      |               ^
b.cpp:3:15: note: also found
    3 | constexpr int x = 0;
      |               ^
1 error generated.
```

I believe this code should be accepted and have the same behavior as if `x` were declared `static` in both `module a` and `module b`. `x` has module linkage in both `module a` and `module b`. Because of that, and based on https://eel.is/c++draft/basic.link#8, the two declarations of `x` are not declaring the same entity and thus the error is incorrect.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VW2TozYM_jXOFw0MmBDCBz7sXprO_Qy_iODW2Iwtkty_7xjI5na7velNrwwTiCSe55Fk2SJGc3GIHatfWX3aiZkGHzotrkZH8g530utv3e_mig5oQOi9tf5m3AVoCIhAQbhoBRnvYHaGIqteWHFixeP3UKy3Yvw13YsV75MPBKPXs0UQrHr9_hvlXSS8TwGMI7gDq05QfIjZEK7eaBCMHxlvgTVvIS3jx-RjvL0_v2xOH0T9rFL5H5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