1 /* This test code is from Wendell Baker (wbaker@comet.berkeley.edu) */
20 f(int i
, char c
, double d
)
24 f(int i
, char c
, double d
, char *cs
)
28 f(int i
, char c
, double d
, char *cs
, void (*fig
)(int, char))
32 f(int i
, char c
, double d
, char *cs
, void (*fig
)(char, int))
48 char g(char, const char, volatile char)
50 char g(R
, char&, const char&, volatile char&)
52 char g(char*, const char*, volatile char*)
54 char g(S
, char*&, const char*&, volatile char*&)
57 signed char g(T
,signed char, const signed char, volatile signed char)
59 signed char g(T
, R
, signed char&, const signed char&, volatile signed char&)
61 signed char g(T
, signed char*, const signed char*, volatile signed char*)
63 signed char g(T
, S
, signed char*&, const signed char*&, volatile signed char*&)
66 unsigned char g(unsigned char, const unsigned char, volatile unsigned char)
68 unsigned char g(R
, unsigned char&, const unsigned char&, volatile unsigned char&)
70 unsigned char g(unsigned char*, const unsigned char*, volatile unsigned char*)
72 unsigned char g(S
, unsigned char*&, const unsigned char*&, volatile unsigned char*&)
75 short g(short, const short, volatile short)
77 short g(R
, short&, const short&, volatile short&)
79 short g(short*, const short*, volatile short*)
81 short g(S
, short*&, const short*&, volatile short*&)
84 signed short g(T
, signed short, const signed short, volatile signed short)
86 signed short g(T
, R
, signed short&, const signed short&, volatile signed short&)
88 signed short g(T
, signed short*, const signed short*, volatile signed short*)
90 signed short g(T
, S
, double, signed short*&, const signed short*&, volatile signed short*&)
93 unsigned short g(unsigned short, const unsigned short, volatile unsigned short)
95 unsigned short g(R
, unsigned short&, const unsigned short&, volatile unsigned short&)
97 unsigned short g(unsigned short*, const unsigned short*, volatile unsigned short*)
99 unsigned short g(S
, unsigned short*&, const unsigned short*&, volatile unsigned short*&)
102 int g(int, const int, volatile int)
104 int g(R
, int&, const int&, volatile int&)
106 int g(int*, const int*, volatile int*)
108 int g(S
, int*&, const int*&, volatile int*&)
111 signed int g(T
, signed int, const signed int, volatile signed int)
113 signed int g(T
, R
, signed int&, const signed int&, volatile signed int&)
115 signed int g(T
, signed int*, const signed int*, volatile signed int*)
117 signed int g(T
, S
, signed int*&, const signed int*&, volatile signed int*&)
120 unsigned int g(unsigned int, const unsigned int, volatile unsigned int)
122 unsigned int g(R
, unsigned int&, const unsigned int&, volatile unsigned int&)
124 unsigned int g(unsigned int*, const unsigned int*, volatile unsigned int*)
126 unsigned int g(S
, unsigned int*&, const unsigned int*&, volatile unsigned int*&)
129 long g(long, const long, volatile long)
131 long g(R
, long&, const long&, volatile long&)
133 long g(long*, const long*, volatile long*)
135 long g(S
, long*&, const long*&, volatile long*&)
138 signed long g(T
, signed long, const signed long, volatile signed long)
140 signed long g(T
, R
, signed long&, const signed long&, volatile signed long&)
142 signed long g(T
, signed long*, const signed long*, volatile signed long*)
144 signed long g(T
, S
, signed long*&, const signed long*&, volatile signed long*&)
147 unsigned long g(unsigned long, const unsigned long, volatile unsigned long)
149 unsigned long g(S
, unsigned long&, const unsigned long&, volatile unsigned long&)
151 unsigned long g(unsigned long*, const unsigned long*, volatile unsigned long*)
153 unsigned long g(S
, unsigned long*&, const unsigned long*&, volatile unsigned long*&)
157 long long g(long long, const long long, volatile long long)
159 long long g(S
, long long&, const long long&, volatile long long&)
161 long long g(long long*, const long long*, volatile long long*)
163 long long g(R
, long long*&, const long long*&, volatile long long*&)
166 signed long long g(T
, signed long long, const signed long long, volatile signed long long)
168 signed long long g(T
, R
, signed long long&, const signed long long&, volatile signed long long&)
170 signed long long g(T
, signed long long*, const signed long long*, volatile signed long long*)
172 signed long long g(T
, S
, signed long long*&, const signed long long*&, volatile signed long long*&)
175 unsigned long long g(unsigned long long, const unsigned long long, volatile unsigned long long)
177 unsigned long long g(R
, unsigned long long*, const unsigned long long*, volatile unsigned long long*)
179 unsigned long long g(unsigned long long&, const unsigned long long&, volatile unsigned long long&)
181 unsigned long long g(S
, unsigned long long*&, const unsigned long long*&, volatile unsigned long long*&)
185 float g(float, const float, volatile float)
187 float g(char, float&, const float&, volatile float&)
189 float g(float*, const float*, volatile float*)
191 float g(char, float*&, const float*&, volatile float*&)
194 double g(double, const double, volatile double)
196 double g(char, double&, const double&, volatile double&)
198 double g(double*, const double*, volatile double*)
200 double g(char, double*&, const double*&, volatile double*&)
204 long double g(long double, const long double, volatile long double)
206 long double g(char, long double&, const long double&, volatile long double&)
208 long double g(long double*, const long double*, volatile long double*)
210 long double g(char, long double*&, const long double*&, volatile long double*&)
220 class c
g(c
, const c
, volatile c
)
222 c
g(char, c
&, const c
&, volatile c
&)
224 c
g(c
*, const c
*, volatile c
*)
226 c
g(char, c
*&, const c
*&, volatile c
*&)
232 void h(char, signed char = 'a')
234 void h(unsigned char = 'a')
238 void h(char = (char)'a')
240 void h(char, signed char = (signed char)'a')
242 void h(unsigned char = (unsigned char)'a')
246 void h(short = (short)43)
248 void h(char, signed short = (signed short)43)
250 void h(unsigned short = (unsigned short)43)
253 void h(int = (int)43)
255 void h(char, signed int = (signed int)43)
257 void h(unsigned int = (unsigned int)43)
261 void h(long = (long)43)
263 void h(char, signed long = (signed long)43)
265 void h(unsigned long = (unsigned long)43)
269 void h(long long = 43)
271 void h(char, signed long long = 43)
273 void h(unsigned long long = 43)
277 void h(float = 4.3e-10)
282 void h(long double = 4.33e33)
287 /* An unneeded printf() definition - actually, just a stub - used to occupy
288 this space. It has been removed and replaced with this comment which
289 exists to occupy some lines so that templates.exp won't need adjustment. */
293 static void* operator new(size_t) throw ();
294 static void operator delete(void *pointer
);
296 void operator=(const T1
&);
299 int operator==(int) const;
300 int operator==(const T1
&) const;
301 int operator!=(int) const;
302 int operator!=(const T1
&) const;
304 int operator<=(int) const;
305 int operator<=(const T1
&) const;
306 int operator<(int) const;
307 int operator<(const T1
&) const;
308 int operator>=(int) const;
309 int operator>=(const T1
&) const;
310 int operator>(int) const;
311 int operator>(const T1
&) const;
313 void operator+(int) const;
314 T1
& operator+(const T1
&) const;
315 void operator+=(int) const;
316 T1
& operator+=(const T1
&) const;
318 T1
& operator++() const;
320 void operator-(int) const;
321 T1
& operator-(const T1
&) const;
322 void operator-=(int) const;
323 T1
& operator-=(const T1
&) const;
325 T1
& operator--() const;
327 void operator*(int) const;
328 T1
& operator*(const T1
&) const;
329 void operator*=(int) const;
330 T1
& operator*=(const T1
&) const;
332 void operator/(int) const;
333 T1
& operator/(const T1
&) const;
334 void operator/=(int) const;
335 T1
& operator/=(const T1
&) const;
337 void operator%(int) const;
338 T1
& operator%(const T1
&) const;
339 void operator%=(int) const;
340 T1
& operator%=(const T1
&) const;
342 void operator&&(int) const;
343 T1
& operator&&(const T1
&) const;
345 void operator||(int) const;
346 T1
& operator||(const T1
&) const;
348 void operator&(int) const;
349 T1
& operator&(const T1
&) const;
350 void operator&=(int) const;
351 T1
& operator&=(const T1
&) const;
353 void operator|(int) const;
354 T1
& operator|(const T1
&) const;
355 void operator|=(int) const;
356 T1
& operator|=(const T1
&) const;
358 void operator^(int) const;
359 T1
& operator^(const T1
&) const;
360 void operator^=(int) const;
361 T1
& operator^=(const T1
&) const;
363 T1
& operator!() const;
364 T1
& operator~() const;
368 T1::operator new(size_t) throw ()
372 T1::operator delete(void *pointer
)
377 T2(int i
): integer(i
)
382 int operator==(const T2
&, const T2
&)
384 int operator==(const T2
&, char)
386 int operator!=(const T2
&, const T2
&)
388 int operator!=(const T2
&, char)
391 int operator<=(const T2
&, const T2
&)
393 int operator<=(const T2
&, char)
395 int operator<(const T2
&, const T2
&)
397 int operator<(const T2
&, char)
399 int operator>=(const T2
&, const T2
&)
401 int operator>=(const T2
&, char)
403 int operator>(const T2
&, const T2
&)
405 int operator>(const T2
&, char)
408 T2
operator+(const T2 t
, int i
)
409 { return t
.integer
+ i
; }
410 T2
operator+(const T2 a
, const T2
& b
)
411 { return a
.integer
+ b
.integer
; }
412 T2
& operator+=(T2
& t
, int i
)
413 { t
.integer
+= i
; return t
; }
414 T2
& operator+=(T2
& a
, const T2
& b
)
415 { a
.integer
+= b
.integer
; return a
; }
417 T2
operator-(const T2 t
, int i
)
418 { return t
.integer
- i
; }
419 T2
operator-(const T2 a
, const T2
& b
)
420 { return a
.integer
- b
.integer
; }
421 T2
& operator-=(T2
& t
, int i
)
422 { t
.integer
-= i
; return t
; }
423 T2
& operator-=(T2
& a
, const T2
& b
)
424 { a
.integer
-= b
.integer
; return a
; }
426 T2
operator*(const T2 t
, int i
)
427 { return t
.integer
* i
; }
428 T2
operator*(const T2 a
, const T2
& b
)
429 { return a
.integer
* b
.integer
; }
430 T2
& operator*=(T2
& t
, int i
)
431 { t
.integer
*= i
; return t
; }
432 T2
& operator*=(T2
& a
, const T2
& b
)
433 { a
.integer
*= b
.integer
; return a
; }
435 T2
operator/(const T2 t
, int i
)
436 { return t
.integer
/ i
; }
437 T2
operator/(const T2 a
, const T2
& b
)
438 { return a
.integer
/ b
.integer
; }
439 T2
& operator/=(T2
& t
, int i
)
440 { t
.integer
/= i
; return t
; }
441 T2
& operator/=(T2
& a
, const T2
& b
)
442 { a
.integer
/= b
.integer
; return a
; }
444 T2
operator%(const T2 t
, int i
)
445 { return t
.integer
% i
; }
446 T2
operator%(const T2 a
, const T2
& b
)
447 { return a
.integer
% b
.integer
; }
448 T2
& operator%=(T2
& t
, int i
)
449 { t
.integer
%= i
; return t
; }
450 T2
& operator%=(T2
& a
, const T2
& b
)
451 { a
.integer
%= b
.integer
; return a
; }
459 static void* operator new(size_t) throw ();
460 static void operator delete(void *pointer
);
473 T5
<T
>::T5(const T5
<T
>&)
482 T5
<T
>::operator new(size_t) throw ()
487 T5
<T
>::operator delete(void *pointer
)
496 T
GetMax (T a
, T b
) {
498 result
= (a
>b
)? a
: b
;
499 // set breakpoint on a line with no real code
503 #if ! defined(__GNUC__) || defined(GCC_BUG)
513 T5
<int (*)(char, void *)> t5fi1(3);
514 T5
<int (*)(int, double **, void *)> t5fi2(4);
523 int (*manage
[5])(double,
524 void *(*malloc
)(unsigned size
),
525 void (*free
)(void *pointer
));
526 int (*device
[5])(int open(const char *, unsigned mode
, unsigned perms
, int extra
),
527 int *(*read
)(int fd
, void *place
, unsigned size
),
528 int *(*write
)(int fd
, void *place
, unsigned size
),
529 void (*close
)(int fd
));
533 #if !defined(__GNUC__) || (__GNUC__ > 2) || (__GNUC__ == 2 && __GNUC_MINOR__ >= 6)
534 template class T5
<char>;
535 template class T5
<int>;
536 template class T5
<int (*)(char, void *)>;
537 template class T5
<int (*)(int, double **, void *)>;
538 template class T5
<x
>;
544 static void put(int);
557 // More template kinds. GDB 4.16 didn't handle these, but
558 // Wildebeest does. Note: Assuming HP aCC is used to compile
559 // this file; with g++ or HP cfront or other compilers the
560 // demangling may not get done correctly.
562 // Ordinary template, to be instantiated with different types
572 template<class T
> T Foo
<T
>::foo (int i
, T tt
)
577 // Template with int parameter
579 template<class T
, int sz
>
588 template<class T
, int sz
> T Bar
<T
, sz
>::bar (int i
, T tt
)
596 // function template with int parameter
597 template<class T
> int dummy (T tt
, int i
)
602 // Template with partial specializations
603 template<class T1
, class T2
>
610 template<class T1
, class T2
>
611 T1 Spec
<T1
, T2
>::spec (T2 t2
)
624 T Spec
<T
, T
*>::spec (T
* tp
)
629 // Template with char parameter
630 template<class T
, char sz
>
639 template<class T
, char sz
> T Baz
<T
, sz
>::baz (int i
, T tt
)
647 typedef Baz
<int, 1> intBazOne
;
649 // Template with char * parameter
650 template<class T
, char * sz
>
658 template<class T
, char * sz
> T Qux
<T
, sz
>::qux (int i
, T tt
)
666 // Template with a function pointer parameter
667 template<class T
, int (*f
)(int) >
675 template<class T
, int (*f
)(int)> T Qux1
<T
, f
>::qux (int i
, T tt
)
683 // Some functions to provide as arguments to template
694 // Template for nested instantiations
704 template<class T
> T Garply
<T
>::garply (int i
, T tt
)
715 template<class C
> class Empty
719 template<class C
> class FunctionArg
722 int method(Empty
<void (FunctionArg
<C
>)> &);
725 template<class C
> int FunctionArg
<C
>::method(Empty
<void (FunctionArg
<C
>)> &arg
)
730 Empty
<void(FunctionArg
<int>)> empty
;
731 FunctionArg
<int> arg
;
740 // New tests added here
743 Foo
<char> fchar
={0,0};
744 Foo
<volatile char *> fvpchar
= {0, 0};
747 Bar
<int, (4 > 3)> bint2
;
749 Baz
<int, 's'> bazint
;
750 Baz
<char, 'a'> bazint2
;
752 Qux
<char, string
> quxint2
;
753 Qux
<int, string
> quxint
;
755 Qux1
<int, gf1
> qux11
;
757 int x
= fint
.foo(33, 47);
758 char c
= fchar
.foo(33, 'x');
759 volatile char * cp
= fvpchar
.foo(33, 0);
761 int y
= dummy
<int> (400, 600);
763 int z
= bint
.bar(55, 66);
764 z
+= bint2
.bar(55, 66);
766 c
= bazint2
.baz(4, 'y');
767 c
= quxint2
.qux(4, 'z');
770 y
= quxint
.qux(4, 22);
771 y
+= qux11
.qux(4, 22);
773 y
*= gf1(y
) - gf2(y
);
776 Spec
<int, int *> siip
;
785 Garply
<Garply
<char> > nf
;
790 fc
= nf
.garply (3, fc
);