Debian Codegraph @

clang/test/Modules/pr125999.cppm

raw
1 // RUN: rm -rf %t
2 // RUN: mkdir -p %t
3 // RUN: split-file %s %t
4 //
5 // RUN: %clang_cc1 -std=c++20 %t/foo.cppm -verify -fsyntax-only
6
7 //--- bar.h
8 template <typename T>
9 struct Singleton {
10 static T* instance_;
11 static T* get() {
12 static bool init = false;
13 if (!init) {
14 init = true;
15 instance_ = ::new T();
16 }
17 return instance_;
18 }
19 };
20
21 template <typename T>
22 T* Singleton<T>::instance_ = nullptr;
23
24 struct s{};
25 inline void* foo() {
26 return Singleton<s>::get();
27 }
28
29 //--- foo.cppm
30 // expected-no-diagnostics
31 module;
32 #include "bar.h"
33 export module foo;