
Close https://github.com/llvm/llvm-project/issues/125999 The cause of the problem is, when we instantiate the pending instantiation, the owning module of the TU gets into 'foo' instead of the GMF. The concern of the patch is, I am not sure the point of 'pending' instantiations. I mean, if there is a reason we **must** pending the intantiations to the end of the TU.
34 lines
607 B
C++
34 lines
607 B
C++
// RUN: rm -rf %t
|
|
// RUN: mkdir -p %t
|
|
// RUN: split-file %s %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/foo.cppm -verify -fsyntax-only
|
|
|
|
//--- bar.h
|
|
template <typename T>
|
|
struct Singleton {
|
|
static T* instance_;
|
|
static T* get() {
|
|
static bool init = false;
|
|
if (!init) {
|
|
init = true;
|
|
instance_ = ::new T();
|
|
}
|
|
return instance_;
|
|
}
|
|
};
|
|
|
|
template <typename T>
|
|
T* Singleton<T>::instance_ = nullptr;
|
|
|
|
struct s{};
|
|
inline void* foo() {
|
|
return Singleton<s>::get();
|
|
}
|
|
|
|
//--- foo.cppm
|
|
// expected-no-diagnostics
|
|
module;
|
|
#include "bar.h"
|
|
export module foo;
|