Issue 109879
Summary [clang] Asserts in ADL when finding exported declaration in the implicit global module
Labels clang
Assignees mizvekov
Reporter mizvekov
    Repro:
```C++
//--- A.cppm
module;
export module A;
export extern "C" void foo(struct Bar);

//--- B.cppm
module;
import A;
export module B;

//--- C.cpp
import B;
struct Bar {};
void test() {
 foo(Bar());
}
```

Crashes with:
```
Assertion failed: (FM && FM->isNamedModule() && !FM->isPrivateModule() && "bad export context"), function ArgumentDependentLookup, file SemaLookup.cpp, line 3854.
```

This is not just a crash on invalid. Slightly more complex, but valid, example:
```C++
//--- foo.h
struct Bar {};
extern "C" void foo(struct Bar);

//--- A.cppm
module;
#include "foo.h"
export module A;
export extern "C" using ::foo;
//--- B.cppm
module;
import A;
export module B;

//--- C.cpp
// expected-no-diagnostics
import B;
#include "foo.h"
void test() {
  foo(Bar());
}
```

It seems the comment above the assert is correct, but the assert itself is missing the implicit global module case, which is also in module purview.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to