Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / cxx2b-deducing-this-constexpr.cpp
blob9dbea17dd2cae34ca8f6675563db98ce93859f61
1 // RUN: %clang_cc1 -fsyntax-only -std=c++2b %s -verify
2 // expected-no-diagnostics
4 template <typename Base>
5 struct Wrap : Base {
7 };
9 struct S {
10 constexpr int f(this const S&) {
11 return 42;
13 constexpr int f(this const S&, auto&&... args) {
14 return (args + ... + 0);
16 constexpr int operator[](this const S&) {
17 return 42;
19 constexpr int operator[](this const S& self, int i) {
20 return i + self.base;
22 constexpr int operator()(this const S&) {
23 return 42;
25 constexpr int operator()(this const S& self, int i) {
26 return self.base + i;
28 constexpr bool operator==(this const S& self, auto && test) {
29 return self.base == test;
31 constexpr int operator*(this const S& self) {
32 return self.base + 22;
34 constexpr operator Wrap<S> (this const S& self) {
35 return Wrap<S>{self};
37 constexpr int operator <<(this Wrap<S> self, int i) {
38 return self.base+i;
41 int base = 20;
44 consteval void test() {
45 constexpr S s;
46 static_assert(s.f() == 42);
47 static_assert(s[] == 42);
48 static_assert(s[22] == 42);
49 static_assert(s.f() == 42);
50 static_assert(s() == 42);
51 static_assert(s(22) == 42);
52 static_assert(s == 20);
53 static_assert(s != 0);
54 static_assert(*s == 42);
55 static_assert((s << 11) == 31);
58 namespace GH68070 {
60 constexpr auto f = [x = 3]<typename Self>(this Self&& self) {
61 return x;
64 auto g = [x = 3]<typename Self>(this Self&& self) {
65 return x;
68 int test() {
69 constexpr int a = f();
70 static_assert(a == 3);
71 return f() + g();