1 // PR c++/88548
2 // { dg-do compile { target c++11 } }
3 
4 struct S1 {
5   int a;
6   auto m1 () -> decltype(this->a) { return 0; }
7   auto m2 () -> decltype(this) { return 0; }
m3S18   void m3 () noexcept(noexcept(this->a)) { }
m4S19   void m4 () noexcept(noexcept(this)) { }
10 
11   static auto m5 () -> decltype(this->a) { return 0; } // { dg-error ".this. may not be used in this context" }
12   static auto m6 () -> decltype(this) { return 0; } // { dg-error ".this. may not be used in this context" }
m7S113   static void m7 () noexcept(noexcept(this->a)) { } // { dg-error ".this. may not be used in this context" }
m8S114   static void m8 () noexcept(noexcept(this)) { } // { dg-error ".this. may not be used in this context" }
15 };
16 
17 template <typename T>
18 struct S2 {
19   static auto f1(T arg) -> decltype((arg));
20 };
21 
22 struct S3 {
23   int a;
f1S324   void f1 () noexcept(noexcept(a)) { }
f2S325   static void f2() noexcept(noexcept(a)) { }
26   static auto f3() -> decltype(a);
27   static auto f4() -> decltype((a));
28 };
29 
30 template<typename T>
31 class S4 {
32   T i;
foo(const S4 & t)33   friend int foo(const S4 &t) noexcept(noexcept(i)) { return t.i; }
34 };
35 
36 void
test()37 test ()
38 {
39   S4<int> t;
40   foo(t);
41 }
42 
43 struct S5 {
44   friend auto bar() -> decltype(this); // { dg-error ".this. may not be used in this context" }
45   auto bar2() -> decltype(this);
46 };
47