1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2011-2017 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
18 Contributed by Red Hat, originally written by Keith Seitz. */
22 typedef const char* const* my_type
;
23 typedef int my_type_2
;
24 typedef my_type my_other_type
;
25 typedef my_type_2 my_other_type_2
;
26 typedef unsigned long CORE_ADDR
;
27 typedef enum {E_A
, E_B
, E_C
} anon_enum
;
28 typedef struct {int a
; char b
;} anon_struct
;
29 typedef union {int a
; char b
;} anon_union
;
30 typedef anon_enum aenum
;
31 typedef anon_struct astruct
;
32 typedef anon_union aunion
;
34 typedef void (*fptr1
) (my_other_type
);
35 typedef void (*fptr2
) (fptr1
, my_other_type_2
);
36 typedef void (*fptr3
) (fptr2
, my_other_type
);
37 typedef void (*fptr4
) (anon_enum a
, anon_struct
const& b
, anon_union
const*** c
);
45 foo (my_other_type a
) { } // A::FOO::foo(my_other_type)
46 foo (my_other_type_2 a
) { } // A::FOO::foo(my_other_type_2)
47 foo (my_other_type_2 a
, const my_other_type b
) { } // A::FOO::foo(my_other_type_2, const my_other_type)
48 foo (fptr3
) { } // A::FOO::foo(fptr3)
49 foo (fptr1
* a
) { } // A::FOO::foo(fptr1*)
50 foo (CORE_ADDR (*) [10]) { } // A::FOO::foo(CORE_ADDR (*) [10])
51 foo (aenum a
, astruct
const& b
, aunion
const*** c
) { } // A::FOO::foo(aenum, astruct const&, aunion const***)
53 void test (my_other_type a
) { } // A::FOO::test(my_other_type)
54 void test (my_other_type_2 a
) { } // A::FOO::test(my_other_type_2)
55 void test (my_other_type_2 a
, const my_other_type b
) { } // A::FOO::test(my_other_type_2, const my_other_type)
56 void test (fptr3 a
) { } // A::FOO::test(fptr3)
57 void test (fptr1
* a
) { } // A::FOO::test(fptr1*)
58 void test (CORE_ADDR (*) [10]) { } // A::FOO::test(CORE_ADDR (*) [10])
59 void test (aenum a
, astruct
const& b
, aunion
const*** c
) { }; // A::FOO::test(aenum, astruct const&, aunion const***)
68 test (my_other_type foo
) { } // B::test(my_other_type)
71 test (aenum a
, astruct
const& b
, aunion
const*** c
) { } // B::test(aenum, astruct const&, aunion const***)
73 template <typename T1
, typename T2
>
74 void test (T1 a
, T2 b
) { } // B::test (T1, T2)
77 void test (my_other_type foo
, my_other_type_2
) { } // B::test<my_other_type, my_other_type_2>(my_other_type, my_other_type_2)
92 typedef c::d::bar BAR
;
96 typedef a::b::BAR _BAR_
;
98 template <typename T1
, typename T2
>
99 void test (T1 a
, T2 b
) {} // test (T1, T2)
102 void test (my_other_type foo
, my_other_type_2
) { } // test<my_other_type, my_other_type_2>(my_other_type, my_other_type_2)
105 test (my_other_type foo
) { } // test(my_other_type)
108 test (_BAR_
&b
) { } // test(_BAR_&)
111 test (aenum a
, astruct
const& b
, aunion
const*** c
) { } // test(aenum, astruct const&, aunion const***)
118 astruct as
= { 0, 0 };
119 aunion
const au
= { 0 };
120 aunion
const* aup
= &au
;
121 aunion
const** aupp
= &aup
;
122 aunion
const*** auppp
= &aupp
;
124 my_foo
.test (static_cast<my_other_type
> (NULL
));
126 my_foo
.test (0, static_cast<my_type
> (NULL
));
127 my_foo
.test (static_cast<fptr3
> (NULL
));
129 my_foo
.test (static_cast<CORE_ADDR (*) [10]> (0));
130 my_foo
.test (E_A
, as
, auppp
);
132 B::test (static_cast<my_other_type
> (NULL
));
133 B::test (static_cast<my_other_type
> (NULL
), 0);
134 B::test (E_A
, as
, auppp
);
136 test (static_cast<my_other_type
> (NULL
));
137 test
<my_other_type
, my_other_type_2
> (static_cast<my_other_type
> (NULL
), 0);
138 test (E_A
, as
, auppp
);
140 A::foo
a (static_cast<my_other_type
> (NULL
));
142 A::foo
c (0, static_cast<my_other_type
> (NULL
));
143 A::foo
d (static_cast<fptr3
> (NULL
));
145 A::foo
f (static_cast<CORE_ADDR (*) [10]> (0));
146 A::foo
g (E_A
, as
, auppp
);