| 1 |
// RUN: %clang_cc1 -verify -fsyntax-only %s |
| 2 |
// expected-no-diagnostics |
| 3 |
|
| 4 |
struct C { |
| 5 |
void f() __restrict { |
| 6 |
static_assert(__is_same(decltype(this), C *__restrict)); |
| 7 |
(void) [this]() { |
| 8 |
static_assert(__is_same(decltype(this), C *__restrict)); |
| 9 |
(void) [this]() { static_assert(__is_same(decltype(this), C *__restrict)); }; |
| 10 |
|
| 11 |
// By-value capture means 'this' is now a different object; do not |
| 12 |
// make it __restrict. |
| 13 |
(void) [*this]() { static_assert(__is_same(decltype(this), const C *)); }; |
| 14 |
(void) [*this]() mutable { static_assert(__is_same(decltype(this), C *)); }; |
| 15 |
}; |
| 16 |
} |
| 17 |
}; |
| 18 |
|
| 19 |
template <typename T> struct TC { |
| 20 |
void f() __restrict { |
| 21 |
static_assert(__is_same(decltype(this), TC<int> *__restrict)); |
| 22 |
(void) [this]() { |
| 23 |
static_assert(__is_same(decltype(this), TC<int> *__restrict)); |
| 24 |
(void) [this]() { static_assert(__is_same(decltype(this), TC<int> *__restrict)); }; |
| 25 |
|
| 26 |
// By-value capture means 'this' is now a different object; do not |
| 27 |
// make it __restrict. |
| 28 |
(void) [*this]() { static_assert(__is_same(decltype(this), const TC<int> *)); }; |
| 29 |
(void) [*this]() mutable { static_assert(__is_same(decltype(this), TC<int> *)); }; |
| 30 |
}; |
| 31 |
} |
| 32 |
}; |
| 33 |
|
| 34 |
void f() { |
| 35 |
TC<int>{}.f(); |
| 36 |
} |
| 37 |
|
| 38 |
namespace gh18121 { |
| 39 |
struct Foo { |
| 40 |
void member() __restrict { |
| 41 |
Foo *__restrict This = this; |
| 42 |
} |
| 43 |
}; |
| 44 |
} |
| 45 |
|
| 46 |
namespace gh42411 { |
| 47 |
struct foo { |
| 48 |
int v; |
| 49 |
void f() const __restrict { |
| 50 |
static_assert(__is_same(decltype((v)), const int&)); |
| 51 |
(void) [this]() { static_assert(__is_same(decltype((v)), const int&)); }; |
| 52 |
} |
| 53 |
}; |
| 54 |
} |
| 55 |
|
| 56 |
namespace gh82941 { |
| 57 |
void f(int& x) { |
| 58 |
(void)x; |
| 59 |
} |
| 60 |
|
| 61 |
class C { |
| 62 |
int x; |
| 63 |
void g() __restrict; |
| 64 |
}; |
| 65 |
|
| 66 |
void C::g() __restrict { |
| 67 |
f(this->x); |
| 68 |
} |
| 69 |
} |