<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/63595>63595</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [Modules] Try to treat `B<A>` and `B<NS::A>` as the same type in using declarations
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:modules
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ChuanqiXu9
</td>
</tr>
</table>
<pre>
This comes from https://reviews.llvm.org/D153003 and revealed by @zygoloid.
The reproducer:
```
// RUN: rm -rf %t
// RUN: mkdir %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
//--- header.h
namespace NS {
template <int I>
class A {
};
template <template <int I_> class T>
class B {
};
}
//--- module1.cppm
// inside NS, using C = B<A>
module;
export module module1;
#include "header.h"
namespace NS {
using C = B<A>;
}
export struct D : NS::C {};
//--- module2.cppm
// inside NS, using C = B<NS::A>
module;
export module module2;
#include "header.h"
namespace NS {
using C = B<NS::A>;
}
export struct D : NS::C {};
//--- merge.cpp
// expected-no-diagnostics
import module1;
import module2;
D d;
```
The explanation is: [temp.type]/1.4 (http://eel.is/c++draft/temp.type#1.4)
> Two template-ids are the same if [...] their corresponding template template-arguments refer to the same template.
so B<A> and B<NS::A> are the same type. The stricter "same sequence of tokens" rule doesn't apply here, because using-declarations are not definitions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0Vk2P4ygQ_TXkUrJFIE7ahxySuCPNYfuw0yvtbUSgHLODwQO4p7O_foWdL3f3rDSrWSlKlCp4j3r1ASIEfbSIa1JsSVHNRB8b59e7phf2m_6zL2cHp07r50YHkK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