Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / SemaCXX / cxx2b-deducing-this-constexpr.cpp
blob191fb013e0316f3136971d78be6e20390e0d02f6
1 // RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify
2 // RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify -fexperimental-new-constant-interpreter
3 // expected-no-diagnostics
5 template <typename Base>
6 struct Wrap : Base {
8 };
10 struct S {
11 constexpr int f(this const S&) {
12 return 42;
14 constexpr int f(this const S&, auto&&... args) {
15 return (args + ... + 0);
17 constexpr int operator[](this const S&) {
18 return 42;
20 constexpr int operator[](this const S& self, int i) {
21 return i + self.base;
23 constexpr int operator()(this const S&) {
24 return 42;
26 constexpr int operator()(this const S& self, int i) {
27 return self.base + i;
29 constexpr bool operator==(this const S& self, auto && test) {
30 return self.base == test;
32 constexpr int operator*(this const S& self) {
33 return self.base + 22;
35 constexpr operator Wrap<S> (this const S& self) {
36 return Wrap<S>{self};
38 constexpr int operator <<(this Wrap<S> self, int i) {
39 return self.base+i;
42 int base = 20;
45 consteval void test() {
46 constexpr S s;
47 static_assert(s.f() == 42);
48 static_assert(s[] == 42);
49 static_assert(s[22] == 42);
50 static_assert(s.f() == 42);
51 static_assert(s() == 42);
52 static_assert(s(22) == 42);
53 static_assert(s == 20);
54 static_assert(s != 0);
55 static_assert(*s == 42);
56 static_assert((s << 11) == 31);
59 namespace GH68070 {
61 constexpr auto f = [x = 3]<typename Self>(this Self&& self) {
62 return x;
65 auto g = [x = 3]<typename Self>(this Self&& self) {
66 return x;
69 int test() {
70 constexpr int a = f();
71 static_assert(a == 3);
72 return f() + g();