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

    <tr>
        <th>Summary</th>
        <td>
            [C++20] [Modules] Crash for inconsistent exportness declarations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:modules,
            crash,
            crash-on-valid
      </td>
    </tr>

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

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

<pre>
    Reproducer:

```
//--- a.cppm
export module m:a;
namespace n {
export class a {
public:
    virtual ~a() {}
};
}

//--- b.cppm
export module m:b;
namespace n {
class a;
}

//--- m.cppm
export module m;
export import :a;
export import :b;

//--- use.cppm
// expected-no-diagnostics
export module u;
export import m;

struct aa : public n::a {
    aa() {}
};
auto foo(n::a*) {
    return;
}
```

Note that we can avoid the crash if we exchange the order of `export import :a` and `export import :b`.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyElEuPmzAQxz-NuYyIHPMIHDjkodzaQ0-9DrYBV8amfqTbSz97BWQ3mzTdlZAtz2D__jN_A3qveiNlQ4oDKU4JxjBY1xyHiOan-h7rpLXid_NNTs6KyKUj2Z7QE6GvY0mvz7pkZ8LOaZoCbvg0jWtUvkzWBRitiFrCSLI9kuyw5gyO0k_IJRggu8PdBq7Re8BbfIqtVvxNAgDARbkQUcMfJKwirF5e3p2ucnanN9At-KC0_VBp-7HSq8TPKeNHlPuy1bhMd236J3XT9UiKXr5jrXGQL5PkQYrU2FQo7I31QXH_TE_8D3R8IPrgIg-AOMuB1RowsznZ_p1ns0n4mTkYg4XOWsKq1xMI27_ueDvHyRCdedLsh1u4jF9tkBAGDPBLAkcDeLFKQBgkcId-ANXNGfnCBzS9XBLWCenAdkBK-sSNkgIa8TTZkpJuVnAimkzUWY2JbLblrspzWuyqZGhaKttyi1XFWS7att6JXJQZ60rcbbEo80Q1jLKMZltKa1Zn1aba0raryyLvRC1o1pGcyhGV3mh9GTfW9YnyPsqm3GZsm2hspfbLp8wY12h6ku1XVz1hjLDjHJ9rv1-l1qQX1ErM4eKUuGY-Pm1j70lOtfLB34BBBb38Lo6EHQg7MEqKE5Di8OUKKk5wXPrbWQfKcGu88kGaAGvTjPQehOQaHQZljU-i080QwuRn65f72qswxHbD7UjYeUZfp3Ry9ofkgbDzUrgn7LzU_jcAAP__l8lknQ">