brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · e78c8e0 Raw
70 lines · cpp
1// RUN: %clang_cc1 -verify -fsyntax-only %s2// expected-no-diagnostics3 4struct 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 not12      // 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 19template <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 not27      // 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 34void f() {35  TC<int>{}.f();36}37 38namespace gh18121 {39struct Foo {40  void member() __restrict {41    Foo *__restrict This = this;42  }43};44}45 46namespace gh42411 {47struct 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 56namespace gh82941 {57void f(int& x) {58    (void)x;59}60 61class C {62    int x;63    void g() __restrict;64};65 66void C::g() __restrict {67    f(this->x);68}69}70