[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / placement-new-bound-member-function.cpp
blob57338942533254f2b8a9e60cf8b0bb75d0818da8
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
3 struct S {
4 int NoArgs();
5 int OneArg(int);
7 template <typename T>
8 T TemplNoArgs(); // expected-note {{possible target for call}} // expected-note {{possible target for call}}
10 template <typename T>
11 T TemplOneArg(T); // expected-note {{possible target for call}} // expected-note {{possible target for call}}
13 void* operator new(__SIZE_TYPE__, int);
16 S* GetS();
18 int test() {
19 S s, *ps = GetS();
20 int (S::*pNoArgs)() = &S::NoArgs;
21 int (S::*pOneArg)(int) = &S::OneArg;
22 int (S::*pTemplNoArgs)() = &S::TemplNoArgs<int>;
23 int (S::*pTemplOneArg)(int) = &S::TemplOneArg<int>;
25 new (s.NoArgs()) S;
26 new (s.OneArg(1)) S;
27 new (ps->NoArgs()) S;
28 new (ps->OneArg(1)) S;
29 new ((s.*pNoArgs)()) S;
30 new ((s.*pOneArg)(1)) S;
31 new ((ps->*pNoArgs)()) S;
32 new ((ps->*pOneArg)(1)) S;
34 new (s.TemplNoArgs<int>()) S;
35 new (s.TemplOneArg<int>(1)) S;
36 new (ps->TemplNoArgs<int>()) S;
37 new (ps->TemplOneArg<int>(1)) S;
38 new ((s.*pTemplNoArgs)()) S;
39 new ((s.*pTemplOneArg)(1)) S;
40 new ((ps->*pTemplNoArgs)()) S;
41 new ((ps->*pTemplOneArg)(1)) S;
43 new (s.NoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
44 new (s.OneArg) S; // expected-error {{reference to non-static member function must be called}}
45 new (ps->NoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
46 new (ps->OneArg) S; // expected-error {{reference to non-static member function must be called}}
47 new (s.*pNoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
48 new (s.*pOneArg) S; // expected-error {{reference to non-static member function must be called}}
49 new (ps->*pNoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
50 new (ps->*pOneArg) S; // expected-error {{reference to non-static member function must be called}}
51 new ((s.*pNoArgs)) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
52 new ((s.*pOneArg)) S; // expected-error {{reference to non-static member function must be called}}
53 new ((ps->*pNoArgs)) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
54 new ((ps->*pOneArg)) S; // expected-error {{reference to non-static member function must be called}}
56 new (s.TemplNoArgs<int>) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
57 new (s.TemplOneArg<int>) S; // expected-error {{reference to non-static member function must be called}}
58 new (ps->TemplNoArgs<int>) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
59 new (ps->TemplOneArg<int>) S; // expected-error {{reference to non-static member function must be called}}
60 new (s.*pTemplNoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
61 new (s.*pTemplOneArg) S; // expected-error {{reference to non-static member function must be called}}
62 new (ps->*pTemplNoArgs) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
63 new (ps->*pTemplOneArg) S; // expected-error {{reference to non-static member function must be called}}
64 new ((s.*pTemplNoArgs)) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
65 new ((s.*pTemplOneArg)) S; // expected-error {{reference to non-static member function must be called}}
66 new ((ps->*pTemplNoArgs)) S; // expected-error {{reference to non-static member function must be called; did you mean to call it with no arguments?}}
67 new ((ps->*pTemplOneArg)) S; // expected-error {{reference to non-static member function must be called}}