<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63047>63047</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang doesn't treat redeclaration of a struct imported from the module as such and makes a new definition instead
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
eaeltsin
</td>
</tr>
</table>
<pre>
Filing the issue reduced by Richard Smith:
[Here](https://godbolt.org/z/x764erhvs) is a reduced testcase:
```
#pragma clang module build std
module std {
module cwchar {}
module ctime {}
}
#pragma clang module contents
#pragma clang module begin std.cwchar
struct tm;
namespace std { using ::tm; }
#pragma clang module end
#pragma clang module begin std.ctime
struct tm {};
#pragma clang module end
#pragma clang module endbuild
#pragma clang module import std.cwchar
using namespace std;
struct tm {};
tm *p;
```
This looks like a Clang bug to me. Something about this setup is causing the definition of struct tm at the end of this testcase to not be treated as a redeclaration of the tm imported from the module. (My guess is that something about the check that we do to see if we should parse a new definition or make the existing imported definition from the std.ctime module visible is getting confused because its name lookup finds both the struct tm declaration and a UsingShadowDecl naming the same thing.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVN1u6zYMfhrlhjiBI9tJfOGLdkGwm92s2wPoh7G1ypJh0u3pnn6QHCen7c5whgMUakxS5Mfvo6iIXBcQW1E_ivq0UTP3cWpRoWdyYaOjfWvPzrvQAfcIjmhGmNDOBi3oN_jdmV5NFp4Gx70oH0RxEsV61o-_4oSiPgl57JlHSgHyLOS5i1ZHz9s4dUKe_xby_PWwr3DqX0jIBhyBulVhJDaK8GP2fXH9Wz5lOU6qGxQYr0IHQ7SzR9Cz8xaI7RJ1tRJbEIfHxbaGmtfUSrYfTlfXzcduwHeu-4__Km9iYAxMPxCqsXMhIdsuQJZg4mk2DDyI8go3qAFpVObWBcyU5En0lA85EO7g_r0WBvv_EKX2PwBa2Vhx_VQpDDYr9QOhbhjjxJ-IWs6FincU3QB-H3k-k10-jHfrh_nK5x-9I_AxPhN494yg4JeMTc8dcIQBt_AUB-Q-wVA6zgycrhDyPKaxNmqBmB6TxYsLjl0MEC9wh6c4uzHYZM_31zeQioTIoBF4QsVoQV3fChqvJrVmSwl4uJKFFi5THLJxYXELQh5_e4NuRqKEi3vFQJ-gI5gezfPifkWwMSEgRHCX9E19nL2FUU2UyAj4-q6rCQb1jEs3Xx1xSn2D9E3gDd1t2Fa1Xxw5nVQn6JBzAhPDZaa0fjCxieCYsuRZmHmEiwuWQEfurzlXYr_lSAULCv5MYjz1ysbXExqf0qzqUMqY2dgK2WxsW9qmbNQG293-WNfNYb-vNn27O-rmWNVVqVSjzV4ZLbXR-11ZNWZ3rMuNa2Uhy2Jf7Iq6rGS1bRopa73b7YwtG1MdRFXgoJzfev8ypI24yVu23ZdFddh4pdFT3s9SJn6zU0iZ1vXUpjtf9NyRqArviOmehR17bJf5tBEpCHngZWw-z4taafrexKQ5o9n0mbikKn3W2wViVHYzT779sO8d97PemjgIeU4Ir_--jFP8Cw0Lec59kZDn3Pc_AQAA__-YSCo0">