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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] [Modules] We shouldn't allow the `import xxx;` to accept `xxx.pcm` which comes from explicit clang modules
        </td>
    </tr>

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

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

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

<pre>
    Currently, possibly due to we reused a lot of logics from clang modules to implement C++20 modules, the c++20 modules style import can accept explicit clang modules surprisingly. But this is not what we want for sure. We should prevent this.

Reproducer:

```
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I%t -fmodule-name=a0 -x c++ -emit-module %t/module.modulemap -o %t/a0.pcm
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=%t/a0.pcm -verify -fsyntax-only
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fmodule-file=a0=%t/a0.pcm -verify -fsyntax-only
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t -verify -fsyntax-only

//--- module.modulemap
module a0 { header "a0.h" export * }

//--- a0.h
void a0() {}

//--- use.cpp
// expected-no-diagnostics
import a0;
void use() {
 a0();
}

```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VE-PuzYQ_TTOZWRkTCDJgcNmo0g9tIefVLW3ypghuDXY9Z8N-faVgST72-5WqlRVimLheTPzeMM84b26jIg1KY-E89c-ivFP9Ws8EM5JedqIGHrj6uf9pjHtrX6NzuEY9I3wV7DGe9XoG7QRIRi4IjiMHlsQoE0A04E2FyU9dM4MILUYLzCYNmr0Ca8Gq3HAMcAr4UfCj5zdw6l86BHkxwD4cNOYUo0LIMUIQkq0AXCyWkkVPrTx0VmnvBov-pbBMQYIvfKgPIwmwLUXIdG-ijFAZ1yCYwa_IPjeRN2CdfiWCKakjLATYS_L_ze0zrRRoiPFy_sAqdj6Wx75mfAzfPv5J1K8gBuAug4IL8Nn4eGPVjmg9kuAt1oF2imNCeL_hvssh_ByluQ3KXOgPrSkOD1lpd1dKdqleSQJ6XJFB2H9E0ClkD1SK0JPilPqDPSH5VghdBQDkuIkGNDpPjqgODxKLoT5eXnKlmMQFqi5hwTLrBz-_Yus6dFjJq19ckpirXwf1YG-oVPdDWjnb2MQEzWjvv3nPQX73xpbh01U-jG676b0Dz3fdaaUwse5LPF1doIB2R2hR9GiA8K5YFlPOE-rl5aR8Bcgu9PnlWfsfPdmVAuCEb4n_JAqfpmzvt538uBkUQZs6Whoq8RlND4o6RfM6gpJ9-O7ZtHju27z_YPAA_mRxX2NN21dtIfiIDZY59WB821eFvtNXxf7Hcu5RI5t0_Gq2TNR8K48YLc_8JxVG1Vzxgu2z3esYGWxz7b7Ns8lVs0hl3zLKrJlOAilM63fhsy4y0Z5H7Gutruy3GjRoParP8_fAileHvY4m7SrUyZt4sWTLdPKB_-sFVTQs70_zJWUJyDl8ce1Rnl6Gt1I-C6A0NpcZ98lFVvFnKYpaVSx5Nir15KKTdM072nF4Nor2YM0A65G_7kVb6LTdR-C9ckx52leVOhjk0kzEH5OxNeDWmd-R5k-8VkRT_h5FuWvAAAA__-BugUO">