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)
26 CHECK_DECLTYPE(decltype(&A::x), int A::*);
27 decltype(&A::y) Ay; // { dg-error "cannot create pointer to reference member|invalid type" }
28 CHECK_DECLTYPE(decltype(&A::foo), int (A::*) (char));
29 CHECK_DECLTYPE(decltype(&A::bar), int& (A::*) () const);
31 CHECK_DECLTYPE(decltype("decltype"), const char(&)[9]);
32 CHECK_DECLTYPE(decltype(1), int);
38 CHECK_DECLTYPE(decltype(i)&, int&);
39 CHECK_DECLTYPE(const decltype(j), const int);
42 CHECK_DECLTYPE(decltype(foo()), int);
44 CHECK_DECLTYPE(decltype (bar(1)), float&);
46 CHECK_DECLTYPE(decltype (bar()), const A);
48 CHECK_DECLTYPE(decltype (bar2()), const A&);
51 CHECK_DECLTYPE(decltype(1+2), int);
53 CHECK_DECLTYPE(decltype(*p), int&);
55 CHECK_DECLTYPE(decltype(a[3]), int&);
57 CHECK_DECLTYPE(decltype (i = 5), int&);
58 CHECK_DECLTYPE(decltype (j = 5), int&);
60 CHECK_DECLTYPE(decltype (++i), int&);
61 CHECK_DECLTYPE(decltype (i++), int);
70 CHECK_DECLTYPE(decltype(bit), int);
71 CHECK_DECLTYPE(decltype((bit)), int&);
72 CHECK_DECLTYPE(decltype(cbit), const int);
73 CHECK_DECLTYPE(decltype((cbit)), const int&);
79 CHECK_DECLTYPE(decltype(b.bit), int);
80 CHECK_DECLTYPE(decltype(bc.bit), int);
81 CHECK_DECLTYPE(decltype((b.bit)), int&);
82 CHECK_DECLTYPE(decltype((bc.bit)), const int&);