OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [decltype2.C] - Blame information for rev 338

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 301 jeremybenn
// { dg-do "compile" }
2
// { dg-options "-std=gnu++0x" }
3
 
4
template
5
struct is_same
6
{
7
  static const bool value = false;
8
};
9
 
10
template
11
struct is_same
12
{
13
  static const bool value = true;
14
};
15
 
16
#define CHECK_DECLTYPE(DECLTYPE,RESULT) \
17
  static_assert(is_same< DECLTYPE , RESULT >::value, #RESULT)
18
 
19
struct A {};
20
 
21
int a;
22
int& b = a;
23
const int& c = a;
24
const int d = 5;
25
const A e = A();
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);
31
 
32
CHECK_DECLTYPE(decltype(a), int);
33
CHECK_DECLTYPE(decltype((a)), int&);
34
 
35
void foo_check(int a, int& b, float& c, int* d)
36
{
37
  CHECK_DECLTYPE(decltype(a), int);
38
  CHECK_DECLTYPE(decltype(b), int&);
39
  CHECK_DECLTYPE(decltype(c), float&);
40
  CHECK_DECLTYPE(decltype(d), int*);
41
}
42
 
43
int foo(char);
44
int bar(char);
45
int bar(int);
46
CHECK_DECLTYPE(decltype(foo), int(char));
47
 
48
decltype(bar) z; // { dg-error "overload" }
49
// { dg-error "invalid type" "" { target *-*-* } 48 }
50
 
51
CHECK_DECLTYPE(decltype(&foo), int(*)(char));
52
CHECK_DECLTYPE(decltype(*&foo), int(&)(char));
53
 
54
void array_types()
55
{
56
  int a[10];
57
  CHECK_DECLTYPE(decltype(a), int[10]);
58
}
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.