Clang Project

clang_source_code/test/SemaTemplate/late-parsing-eager-instantiation.cpp
1// RUN: %clang_cc1 -std=c++14 -verify %s
2
3// pr33561
4class ArrayBuffer;
5template <typename T> class Trans_NS_WTF_RefPtr {
6public:
7  ArrayBuffer *operator->() { return nullptr; }
8};
9Trans_NS_WTF_RefPtr<ArrayBuffer> get();
10template <typename _Visitor>
11constexpr void visit(_Visitor __visitor) {
12  __visitor(get()); // expected-note {{in instantiation}}
13}
14class ArrayBuffer {
15  char data() {
16    visit([](auto buffer) -> char { // expected-note {{in instantiation}}
17      buffer->data();
18    }); // expected-warning {{control reaches end of non-void lambda}}
19  } // expected-warning {{control reaches end of non-void function}}
20};
21
22// pr34185
23template <typename Promise> struct coroutine_handle {
24  Promise &promise() const { return
25    *static_cast<Promise *>(nullptr); // expected-warning {{binding dereferenced null}}
26  }
27};
28
29template <typename Promise> auto GetCurrenPromise() {
30  struct Awaiter { // expected-note {{in instantiation}}
31    void await_suspend(coroutine_handle<Promise> h) {
32      h.promise(); // expected-note {{in instantiation}}
33    }
34  };
35  return Awaiter{};
36}
37
38void foo() {
39  auto &&p = GetCurrenPromise<int>(); // expected-note {{in instantiation}}
40}
41