2 // { dg-options "-std=gnu++0x" }
4 template<typename T, typename U>
7 static const bool value = false;
13 static const bool value = true;
16 #define CHECK_DECLTYPE(DECLTYPE,RESULT) \
17 static_assert(is_same< DECLTYPE , RESULT >::value, #DECLTYPE " should be " #RESULT)
28 CHECK_DECLTYPE(decltype(a), int);
29 CHECK_DECLTYPE(decltype(this->a), int);
30 CHECK_DECLTYPE(decltype((*this).a), int);
31 CHECK_DECLTYPE(decltype(b), int&);
32 CHECK_DECLTYPE(decltype(c), int);
35 CHECK_DECLTYPE(decltype(a), int);
36 CHECK_DECLTYPE(decltype(b), int&);
37 CHECK_DECLTYPE(decltype(c), int);
44 CHECK_DECLTYPE(decltype(aa.a), int);
45 CHECK_DECLTYPE(decltype(aa.b), int&);
46 CHECK_DECLTYPE(decltype(caa.a), int);
54 decltype(b) enums_are_in_scope() { return b; } // ok
57 CHECK_DECLTYPE(decltype(aa.*&A::a), int&);
58 decltype(aa.*&A::b) zz; // { dg-error "cannot create pointer to reference member" }
59 // { dg-error "invalid type" "" { target *-*-* } 58 }
60 CHECK_DECLTYPE(decltype(caa.*&A::a), const int&);
64 CHECK_DECLTYPE(decltype(this), X*);
65 CHECK_DECLTYPE(decltype(*this), X&);
68 CHECK_DECLTYPE(decltype(this), const X*);
69 CHECK_DECLTYPE(decltype(*this), const X&);