* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / decltype2.C
blob29ba2aa97e2fa9b69c88bac3d703a72c0fa65df9
1 // { dg-do compile { target c++11 } }
3 template<typename T, typename U> 
4 struct is_same 
6   static const bool value = false;
7 };
9 template<typename T>
10 struct is_same<T, T>
12   static const bool value = true;
15 #define CHECK_DECLTYPE(DECLTYPE,RESULT) \
16   static_assert(is_same< DECLTYPE , RESULT >::value, #RESULT)
18 struct A {};
20 int a; 
21 int& b = a; 
22 const int& c = a; 
23 const int d = 5; 
24 const A e = A(); 
25 CHECK_DECLTYPE(decltype(a), int);
26 CHECK_DECLTYPE(decltype(b), int&); 
27 CHECK_DECLTYPE(decltype(c), const int&); 
28 CHECK_DECLTYPE(decltype(d), const int); 
29 CHECK_DECLTYPE(decltype(e), const A); 
31 CHECK_DECLTYPE(decltype(a), int);
32 CHECK_DECLTYPE(decltype((a)), int&);
34 void foo_check(int a, int& b, float& c, int* d) 
35
36   CHECK_DECLTYPE(decltype(a), int);
37   CHECK_DECLTYPE(decltype(b), int&); 
38   CHECK_DECLTYPE(decltype(c), float&);
39   CHECK_DECLTYPE(decltype(d), int*);
40
42 int foo(char); 
43 int bar(char); 
44 int bar(int); 
45 CHECK_DECLTYPE(decltype(foo), int(char));
47 decltype(bar) z; // { dg-error "overload" "overload" }
49 CHECK_DECLTYPE(decltype(&foo), int(*)(char));
50 CHECK_DECLTYPE(decltype(*&foo), int(&)(char));
52 void array_types()
54   int a[10]; 
55   CHECK_DECLTYPE(decltype(a), int[10]);