ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.cp / converts.cc
blobecf806481fdffc6abb19180fa200a9b5b433494c
1 class A
3 public:
4 A() : member_ (0) {};
5 int member_;
6 };
7 class B : public A {};
9 typedef A TA1;
10 typedef A TA2;
11 typedef TA2 TA3;
13 enum my_enum {MY_A, MY_B, MY_C, MY_D};
15 /* Without this variable older 'enum my_enum' incl. its 'MY_A' would be omitted
16 by older versions of GCC (~4.1) failing the testcase using it below. */
17 enum my_enum my_enum_var;
19 int foo0_1 (TA1) { return 1; }
20 int foo0_2 (TA3) { return 2; }
21 int foo0_3 (A***) { return 3; }
23 int foo1_1 (char *) {return 11;}
24 int foo1_2 (char[]) {return 12;}
25 int foo1_3 (int*) {return 13;}
26 int foo1_4 (A*) {return 14;}
27 int foo1_5 (void*) {return 15;}
28 int foo1_6 (void**) {return 16;}
29 int foo1_7 (bool) {return 17;}
30 int foo1_8 (long) {return 18;}
32 int foo2_1 (char** ) {return 21;}
33 int foo2_2 (char[][1]) {return 22;}
34 int foo2_3 (char *[]) {return 23;}
35 int foo2_4 (int *[]) {return 24;}
37 int foo3_1 (int a, const char **b) { return 31; }
38 int foo3_2 (int a, int b) { return 32; }
39 int foo3_2 (int a, const char **b) { return 320; }
41 int foo1_type_check (char *a) { return 1000; }
42 int foo2_type_check (char *a, char *b) { return 1001; }
43 int foo3_type_check (char *a, char *b, char *c) { return 1002; }
45 int main()
48 TA2 ta; // typedef to..
49 foo0_1 (ta); // ..another typedef
50 foo0_2 (ta); // ..typedef of a typedef
52 B*** bppp; // Pointer-to-pointer-to-pointer-to-derived..
53 //foo0_3(bppp); // Pointer-to-pointer-to-pointer base.
54 foo0_3((A***)bppp); // to ensure that the function is emitted.
56 char av = 'a';
57 char *a = &av; // pointer to..
58 B *bp;
59 foo1_1 (a); // ..pointer
60 foo1_2 (a); // ..array
61 foo1_3 ((int*)a); // ..pointer of wrong type
62 foo1_3 ((int*)bp); // ..pointer of wrong type
63 foo1_4 (bp); // ..ancestor pointer
64 foo1_5 (bp); // ..void pointer
65 foo1_6 ((void**)bp); // ..void pointer pointer
66 foo1_7 (bp); // ..boolean
67 foo1_8 ((long)bp); // ..long int
69 char **b; // pointer pointer to..
70 char ba[1][1];
71 foo1_5 (b); // ..void pointer
72 foo2_1 (b); // ..pointer pointer
73 foo2_2 (ba); // ..array of arrays
74 foo2_3 (b); // ..array of pointers
75 foo2_4 ((int**)b); // ..array of wrong pointers
77 // X to boolean conversions allowed by the standard
78 int integer = 0;
79 long long_int = 1;
80 float fp = 1.0;
81 double dp = 1.0;
82 foo1_7 (integer); // integer to boolean
83 foo1_7 (long_int); // long to boolean
84 foo1_7 (*a); // char to boolean
85 foo1_7 (MY_A); // unscoped enum to boolean
86 /* converts.exp tests the next statement directly. It is not compiled
87 here for verification because older versions of GCC (~4.1) fail to
88 compile it:
90 warning: the address of 'int foo1_7(bool)' will always evaluate as true
92 foo1_7 (&foo1_7); // pointer to boolean
95 foo1_7 (&A::member_); // pointer to member to boolean
96 foo1_7 (a); // pointer to boolean
97 foo1_7 (fp); // float to boolean
98 foo1_7 (dp); // double to boolean
100 foo3_1 (0, 0);
101 foo3_2 (0, static_cast<char const**> (0));
102 foo3_2 (0, 0);
104 foo1_type_check (a);
105 foo2_type_check (a, a);
106 foo3_type_check (a, a, a);
108 return 0; // end of main