PR c++/13356
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / converts.cc
1 class A {};
2 class B : public A {};
3
4 typedef A TA1;
5 typedef A TA2;
6 typedef TA2 TA3;
7
8 int foo0_1 (TA1) { return 1; }
9 int foo0_2 (TA3) { return 2; }
10 int foo0_3 (A***) { return 3; }
11
12 int foo1_1 (char *) {return 11;}
13 int foo1_2 (char[]) {return 12;}
14 int foo1_3 (int*) {return 13;}
15 int foo1_4 (A*) {return 14;}
16 int foo1_5 (void*) {return 15;}
17 int foo1_6 (void**) {return 16;}
18 int foo1_7 (bool) {return 17;}
19 int foo1_8 (long) {return 18;}
20
21 int foo2_1 (char** ) {return 21;}
22 int foo2_2 (char[][1]) {return 22;}
23 int foo2_3 (char *[]) {return 23;}
24 int foo2_4 (int *[]) {return 24;}
25
26 int foo3_1 (int a, const char **b) { return 31; }
27 int foo3_2 (int a, int b) { return 32; }
28 int foo3_2 (int a, const char **b) { return 320; }
29
30 int foo1_type_check (char *a) { return 1000; }
31 int foo2_type_check (char *a, char *b) { return 1001; }
32 int foo3_type_check (char *a, char *b, char *c) { return 1002; }
33
34 int main()
35 {
36
37 TA2 ta; // typedef to..
38 foo0_1 (ta); // ..another typedef
39 foo0_2 (ta); // ..typedef of a typedef
40
41 B*** bppp; // Pointer-to-pointer-to-pointer-to-derived..
42 //foo0_3(bppp); // Pointer-to-pointer-to-pointer base.
43 foo0_3((A***)bppp); // to ensure that the function is emitted.
44
45 char *a; // pointer to..
46 B *bp;
47 foo1_1 (a); // ..pointer
48 foo1_2 (a); // ..array
49 foo1_3 ((int*)a); // ..pointer of wrong type
50 foo1_3 ((int*)bp); // ..pointer of wrong type
51 foo1_4 (bp); // ..ancestor pointer
52 foo1_5 (bp); // ..void pointer
53 foo1_6 ((void**)bp); // ..void pointer pointer
54 foo1_7 (bp); // ..boolean
55 foo1_8 ((long)bp); // ..long int
56
57 char **b; // pointer pointer to..
58 char ba[1][1];
59 foo1_5 (b); // ..void pointer
60 foo2_1 (b); // ..pointer pointer
61 foo2_2 (ba); // ..array of arrays
62 foo2_3 (b); // ..array of pointers
63 foo2_4 ((int**)b); // ..array of wrong pointers
64
65 foo3_1 (0, 0);
66 foo3_2 (0, static_cast<char const**> (0));
67 foo3_2 (0, 0);
68
69 foo1_type_check (a);
70 foo2_type_check (a, a);
71 foo3_type_check (a, a, a);
72
73 return 0; // end of main
74 }
This page took 0.039157 seconds and 4 git commands to generate.