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, #RESULT)
26 CHECK_DECLTYPE(decltype(a), int);
27 CHECK_DECLTYPE(decltype(b), int&);
28 CHECK_DECLTYPE(decltype(c), const int&);
29 CHECK_DECLTYPE(decltype(d), const int);
30 CHECK_DECLTYPE(decltype(e), const A);
32 CHECK_DECLTYPE(decltype(a), int);
33 CHECK_DECLTYPE(decltype((a)), int&);
35 void foo_check(int a, int& b, float& c, int* d)
37 CHECK_DECLTYPE(decltype(a), int);
38 CHECK_DECLTYPE(decltype(b), int&);
39 CHECK_DECLTYPE(decltype(c), float&);
40 CHECK_DECLTYPE(decltype(d), int*);
46 CHECK_DECLTYPE(decltype(foo), int(char));
48 decltype(bar) z; // { dg-error "overload" }
49 // { dg-error "invalid type" "" { target *-*-* } 48 }
51 CHECK_DECLTYPE(decltype(&foo), int(*)(char));
52 CHECK_DECLTYPE(decltype(*&foo), int(&)(char));
57 CHECK_DECLTYPE(decltype(a), int[10]);