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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] [Modules] Crash if we enable `-std=c++20` and `-fmodule-ts`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            c++20,
            clang:modules
      </td>
    </tr>

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

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

<pre>
    Here is the reproducer
```
// m.cppm
export module m;

export int m() {
    return 0;
}
```

Run:
```
clang++ -std=c++20 -fmodules-ts --precompile -c m.cppm -o m.pcm 
```

Then it would crash at 
```
clang/lib/Sema/SemaModule.cpp:187: clang::Sema::DeclGroupPtrTy clang::Sema::ActOnModuleDecl(clang::SourceLocation, clang::SourceLocation, clang::Sema::ModuleDeclKind, clang::ModuleIdPath, clang::ModuleIdPath, clang::Sema::ModuleImportState&): Assertion `(!getLangOpts().CPlusPlusModules || SeenGMF == (bool)GlobalModuleFragment) && "mismatched global module state"' failed.
```

It would be OK if we remove the flag ` -fmodules-ts`.

It is meaningless to run `-std=c++20` and `-fmodules-ts` together. But crash is bad after all.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyNVMtuozAU_RrYXAWBSUKyYJGH0qnaqtW0i9ka44BHxmb8aGf-fq6BNG0UVUXGxrnH5z58bipd_yt_cMNBWHAtB8N7o2vPuInSfZRuomU6jXFLDjigS1jfd-NP_G-vjYMOT0kOXZRvJ-hHq1CIiMgqImuIigkB-BjuvFGQno8V--ueh_mnV1G-uQpgkqomIlscMLOujvI9G7ckhdlxjM_OnIXZrDec6a4XGPCMTdnATONXzzr4wv9LyxUIB2_ayxqYobYF6q6fmAI6SFHh_Mw7Oi0PQyjBKeaSrQqcYQRjavlmQA5fe87kjdG-f3Lm5d91zIa5RzUyBjjW-CNMe8P4vWbUCa0isoNvG98dnLnvhKovYKPxtn6irv2-6ZL8tgsieXbU8YgsUSOhIhtruQmRQahokE7WcHePJI-9s6OWkt2T9Da8I5FFce1wwDPn6ubhACgCHIDoSmsszvpG6orKEX0wtOm4coMog98lLqQTtqOOtbyGZgCfpG3H-EhECjhS1E6dfKGU25NIKg6PdyCO8Ba6q9OvfGi0o6RNyOyTNHGfXJBgX3acKqEahGCPajB-KMmlxgMXVfVg-kyJh7ByLTcJbL2bVIu8Fa2BHh03QKVM4rrM63W-prETTvIyWmx379wLrOFiOxU57HYjyZAVV7TC-nwvpjGk2BtZts71Nuhg-FNphGt9lWBfhp6Rr6cFm1X_5gxv6SCs9eieHBZzUqRxWx7zbJnxKlvUecVYUS1YRel8veKrOqMZTWNJKy5tyAUv7hxWuMRduOyTKKd6BcNiH4uSpISkebrKSL5Mi6Rm1XKZphUjK0IKMo_mKUpYyCQEmGjTxKYcYq18Y9EohXX2bKTWikbxoaaBn3rXalPuWk_VH_HLr-Mhs3JI6z87v6nB">