home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / testsuite / gdb.t23 / gdbme.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  12.5 KB  |  523 lines

  1. /* This test code is from Wendell Baker (wbaker@comet.berkeley.edu) */
  2.  
  3. int a_i;
  4. char a_c;
  5. double a_d;
  6.  
  7. typedef void *Pix;
  8.  
  9. int
  10. f(int i)
  11. { return 0; }
  12.  
  13. int
  14. f(int i, char c)
  15. { return 0; }
  16.  
  17. int
  18. f(int i, char c, double d)
  19. { return 0; }
  20.  
  21. int
  22. f(int i, char c, double d, char *cs)
  23. { return 0; }
  24.  
  25. int
  26. f(int i, char c, double d, char *cs, void (*fig)(int, char))
  27. { return 0; }
  28.  
  29. int
  30. f(int i, char c, double d, char *cs, void (*fig)(char, int))
  31. { return 0; }
  32.  
  33. class R {
  34. public:
  35.     int i;
  36. };
  37. class S {
  38. public:
  39.     int i;
  40. };
  41. class T {
  42. public:
  43.     int i;
  44. };
  45.  
  46. char g(char, const char, volatile char)
  47. { return 'c'; }
  48. char g(R, char&, const char&, volatile char&)
  49. { return 'c'; }
  50. char g(char*, const char*, volatile char*)
  51. { return 'c'; }
  52. char g(S, char*&, const char*&, volatile char*&)
  53. { return 'c'; }
  54.  
  55. signed char g(T,signed char, const signed char, volatile signed char)
  56. { return 'c'; }
  57. signed char g(T, R, signed char&, const signed char&, volatile signed char&)
  58. { return 'c'; }
  59. signed char g(T, signed char*, const signed char*, volatile signed char*)
  60. { return 'c'; }
  61. signed char g(T, S, signed char*&, const signed char*&, volatile signed char*&)
  62. { return 'c'; }
  63.  
  64. unsigned char g(unsigned char, const unsigned char, volatile unsigned char)
  65. { return 'c'; }
  66. unsigned char g(R, unsigned char&, const unsigned char&, volatile unsigned char&)
  67. { return 'c'; }
  68. unsigned char g(unsigned char*, const unsigned char*, volatile unsigned char*)
  69. { return 'c'; }
  70. unsigned char g(S, unsigned char*&, const unsigned char*&, volatile unsigned char*&)
  71. { return 'c'; }
  72.  
  73. short g(short, const short, volatile short)
  74. { return 0; }
  75. short g(R, short&, const short&, volatile short&)
  76. { return 0; }
  77. short g(short*, const short*, volatile short*)
  78. { return 0; }
  79. short g(S, short*&, const short*&, volatile short*&)
  80. { return 0; }
  81.  
  82. signed short g(T, signed short, const signed short, volatile signed short)
  83. { return 0; }
  84. signed short g(T, R, signed short&, const signed short&, volatile signed short&)
  85. { return 0; }
  86. signed short g(T, signed short*, const signed short*, volatile signed short*)
  87. { return 0; }
  88. signed short g(T, S, double, signed short*&, const signed short*&, volatile signed short*&)
  89. { return 0; }
  90.  
  91. unsigned short g(unsigned short, const unsigned short, volatile unsigned short)
  92. { return 0; }
  93. unsigned short g(R, unsigned short&, const unsigned short&, volatile unsigned short&)
  94. { return 0; }
  95. unsigned short g(unsigned short*, const unsigned short*, volatile unsigned short*)
  96. { return 0; }
  97. unsigned short g(S, unsigned short*&, const unsigned short*&, volatile unsigned short*&)
  98. { return 0; }
  99.  
  100. int g(int, const int, volatile int)
  101. { return 0; }
  102. int g(R, int&, const int&, volatile int&)
  103. { return 0; }
  104. int g(int*, const int*, volatile int*)
  105. { return 0; }
  106. int g(S, int*&, const int*&, volatile int*&)
  107. { return 0; }
  108.  
  109. signed int g(T, signed int, const signed int, volatile signed int)
  110. { return 0; }
  111. signed int g(T, R, signed int&, const signed int&, volatile signed int&)
  112. { return 0; }
  113. signed int g(T, signed int*, const signed int*, volatile signed int*)
  114. { return 0; }
  115. signed int g(T, S, signed int*&, const signed int*&, volatile signed int*&)
  116. { return 0; }
  117.  
  118. unsigned int g(unsigned int, const unsigned int, volatile unsigned int)
  119. { return 0; }
  120. unsigned int g(R, unsigned int&, const unsigned int&, volatile unsigned int&)
  121. { return 0; }
  122. unsigned int g(unsigned int*, const unsigned int*, volatile unsigned int*)
  123. { return 0; }
  124. unsigned int g(S, unsigned int*&, const unsigned int*&, volatile unsigned int*&)
  125. { return 0; }
  126.  
  127. long g(long, const long, volatile long)
  128. { return 0; }
  129. long g(R, long&, const long&, volatile long&)
  130. { return 0; }
  131. long g(long*, const long*, volatile long*)
  132. { return 0; }
  133. long g(S, long*&, const long*&, volatile long*&)
  134. { return 0; }
  135.  
  136. signed long g(T, signed long, const signed long, volatile signed long)
  137. { return 0; }
  138. signed long g(T, R, signed long&, const signed long&, volatile signed long&)
  139. { return 0; }
  140. signed long g(T, signed long*, const signed long*, volatile signed long*)
  141. { return 0; }
  142. signed long g(T, S, signed long*&, const signed long*&, volatile signed long*&)
  143. { return 0; }
  144.  
  145. unsigned long g(unsigned long, const unsigned long, volatile unsigned long)
  146. { return 0; }
  147. unsigned long g(S, unsigned long&, const unsigned long&, volatile unsigned long&)
  148. { return 0; }
  149. unsigned long g(unsigned long*, const unsigned long*, volatile unsigned long*)
  150. { return 0; }
  151. unsigned long g(S, unsigned long*&, const unsigned long*&, volatile unsigned long*&)
  152. { return 0; }
  153.  
  154. #ifdef __GNUC__
  155. long long g(long long, const long long, volatile long long)
  156. { return 0; }
  157. long long g(S, long long&, const long long&, volatile long long&)
  158. { return 0; }
  159. long long g(long long*, const long long*, volatile long long*)
  160. { return 0; }
  161. long long g(R, long long*&, const long long*&, volatile long long*&)
  162. { return 0; }
  163.  
  164. signed long long g(T, signed long long, const signed long long, volatile signed long long)
  165. { return 0; }
  166. signed long long g(T, R, signed long long&, const signed long long&, volatile signed long long&)
  167. { return 0; }
  168. signed long long g(T, signed long long*, const signed long long*, volatile signed long long*)
  169. { return 0; }
  170. signed long long g(T, S, signed long long*&, const signed long long*&, volatile signed long long*&)
  171. { return 0; }
  172.  
  173. unsigned long long g(unsigned long long, const unsigned long long, volatile unsigned long long)
  174. { return 0; }
  175. unsigned long long g(R, unsigned long long*, const unsigned long long*, volatile unsigned long long*)
  176. { return 0; }
  177. unsigned long long g(unsigned long long&, const unsigned long long&, volatile unsigned long long&)
  178. { return 0; }
  179. unsigned long long g(S, unsigned long long*&, const unsigned long long*&, volatile unsigned long long*&)
  180. { return 0; }
  181. #endif
  182.  
  183. float g(float, const float, volatile float)
  184. { return 0; }
  185. float g(char, float&, const float&, volatile float&)
  186. { return 0; }
  187. float g(float*, const float*, volatile float*)
  188. { return 0; }
  189. float g(char, float*&, const float*&, volatile float*&)
  190. { return 0; }
  191.  
  192. double g(double, const double, volatile double)
  193. { return 0; }
  194. double g(char, double&, const double&, volatile double&)
  195. { return 0; }
  196. double g(double*, const double*, volatile double*)
  197. { return 0; }
  198. double g(char, double*&, const double*&, volatile double*&)
  199. { return 0; }
  200.  
  201. #ifdef __GNUC__
  202. long double g(long double, const long double, volatile long double)
  203. { return 0; }
  204. long double g(char, long double&, const long double&, volatile long double&)
  205. { return 0; }
  206. long double g(long double*, const long double*, volatile long double*)
  207. { return 0; }
  208. long double g(char, long double*&, const long double*&, volatile long double*&)
  209. { return 0; }
  210. #endif
  211.  
  212. class c {
  213. public:
  214.     c(int) {};
  215.     int i;
  216. };
  217.  
  218. class c g(c, const c, volatile c)
  219. { return 0; }
  220. c g(char, c&, const c&, volatile c&)
  221. { return 0; }
  222. c g(c*, const c*, volatile c*)
  223. { return 0; }
  224. c g(char, c*&, const c*&, volatile c*&)
  225. { return 0; }
  226.  
  227. void h(char = 'a')
  228. { }
  229. void h(char, signed char = 'a')
  230. { }
  231. void h(unsigned char = 'a')
  232. { }
  233.  
  234. void h(short = 43)
  235. { }
  236. void h(char, signed short = 43)
  237. { }
  238. void h(unsigned short = 43)
  239. { }
  240.  
  241. void h(int = 43)
  242. { }
  243. void h(char, signed int = 43)
  244. { }
  245. void h(unsigned int = 43)
  246. { }
  247.  
  248. void h(long = 43)
  249. { }
  250. void h(char, signed long = 43)
  251. { }
  252. void h(unsigned long = 43)
  253. { }
  254.  
  255. #ifdef __GNUC__
  256. void h(long long = 43)
  257. { }
  258. void h(char, signed long long = 43)
  259. { }
  260. void h(unsigned long long = 43)
  261. { }
  262. #endif
  263.  
  264. void h(float = 4.3e-10)
  265. { }
  266. void h(double = 4.3)
  267. { }
  268. #ifdef __GNUC__
  269. void h(long double = 4.33e33)
  270. { }
  271. #endif
  272.  
  273. void printf(const char *format, ... )
  274. {
  275.     // elipsis
  276. }
  277.  
  278. class T1 {
  279. public:
  280.     static void* operator new(unsigned size);
  281.     static void operator delete(void *pointer);
  282.  
  283.     void operator=(const T1&);
  284.     T1& operator=(int);
  285.  
  286.     int operator==(int) const;
  287.     int operator==(const T1&) const;
  288.     int operator!=(int) const;
  289.     int operator!=(const T1&) const;
  290.  
  291.     int operator<=(int) const;
  292.     int operator<=(const T1&) const;
  293.     int operator<(int) const;
  294.     int operator<(const T1&) const;
  295.     int operator>=(int) const;
  296.     int operator>=(const T1&) const;
  297.     int operator>(int) const;
  298.     int operator>(const T1&) const;
  299.  
  300.     void operator+(int) const;
  301.     T1& operator+(const T1&) const;
  302.     void operator+=(int) const;
  303.     T1& operator+=(const T1&) const;
  304.  
  305.     T1& operator++() const;
  306.  
  307.     void operator-(int) const;
  308.     T1& operator-(const T1&) const;
  309.     void operator-=(int) const;
  310.     T1& operator-=(const T1&) const;
  311.  
  312.     T1& operator--() const;
  313.  
  314.     void operator*(int) const;
  315.     T1& operator*(const T1&) const;
  316.     void operator*=(int) const;
  317.     T1& operator*=(const T1&) const;
  318.  
  319.     void operator/(int) const;
  320.     T1& operator/(const T1&) const;
  321.     void operator/=(int) const;
  322.     T1& operator/=(const T1&) const;
  323.  
  324.     void operator%(int) const;
  325.     T1& operator%(const T1&) const;
  326.     void operator%=(int) const;
  327.     T1& operator%=(const T1&) const;
  328.  
  329.     void operator&&(int) const;
  330.     T1& operator&&(const T1&) const;
  331.  
  332.     void operator||(int) const;
  333.     T1& operator||(const T1&) const;
  334.  
  335.     void operator&(int) const;
  336.     T1& operator&(const T1&) const;
  337.     void operator&=(int) const;
  338.     T1& operator&=(const T1&) const;
  339.  
  340.     void operator|(int) const;
  341.     T1& operator|(const T1&) const;
  342.     void operator|=(int) const;
  343.     T1& operator|=(const T1&) const;
  344.  
  345.     void operator^(int) const;
  346.     T1& operator^(const T1&) const;
  347.     void operator^=(int) const;
  348.     T1& operator^=(const T1&) const;
  349.  
  350.     T1& operator!() const;
  351.     T1& operator~() const;
  352. };
  353.  
  354. void* 
  355. T1::operator new(unsigned size)
  356. { return 0; }
  357.  
  358. void
  359. T1::operator delete(void *pointer)
  360. { }
  361.  
  362. class T2 {
  363. public:
  364.     T2(int i): integer(i)
  365.     { }
  366.     int integer;
  367. };
  368.  
  369. int operator==(const T2&, const T2&)
  370. { return 0; }
  371. int operator==(const T2&, char)
  372. { return 0; }
  373. int operator!=(const T2&, const T2&)
  374. { return 0; }
  375. int operator!=(const T2&, char)
  376. { return 0; }
  377.  
  378. int operator<=(const T2&, const T2&)
  379. { return 0; }
  380. int operator<=(const T2&, char)
  381. { return 0; }
  382. int operator<(const T2&, const T2&)
  383. { return 0; }
  384. int operator<(const T2&, char)
  385. { return 0; }
  386. int operator>=(const T2&, const T2&)
  387. { return 0; }
  388. int operator>=(const T2&, char)
  389. { return 0; }
  390. int operator>(const T2&, const T2&)
  391. { return 0; }
  392. int operator>(const T2&, char)
  393. { return 0; }
  394.  
  395. T2 operator+(const T2 t, int i)
  396. { return t.integer + i; }
  397. T2 operator+(const T2 a, const T2& b)
  398. { return a.integer + b.integer; }
  399. T2& operator+=(T2& t, int i)
  400. { t.integer += i; return t; }
  401. T2& operator+=(T2& a, const T2& b)
  402. { a.integer += b.integer; return a; }
  403.  
  404. T2 operator-(const T2 t, int i)
  405. { return t.integer - i; }
  406. T2 operator-(const T2 a, const T2& b)
  407. { return a.integer - b.integer; }
  408. T2& operator-=(T2& t, int i)
  409. { t.integer -= i; return t; }
  410. T2& operator-=(T2& a, const T2& b)
  411. { a.integer -= b.integer; return a; }
  412.  
  413. T2 operator*(const T2 t, int i)
  414. { return t.integer * i; }
  415. T2 operator*(const T2 a, const T2& b)
  416. { return a.integer * b.integer; }
  417. T2& operator*=(T2& t, int i)
  418. { t.integer *= i; return t; }
  419. T2& operator*=(T2& a, const T2& b)
  420. { a.integer *= b.integer; return a; }
  421.  
  422. T2 operator/(const T2 t, int i)
  423. { return t.integer / i; }
  424. T2 operator/(const T2 a, const T2& b)
  425. { return a.integer / b.integer; }
  426. T2& operator/=(T2& t, int i)
  427. { t.integer /= i; return t; }
  428. T2& operator/=(T2& a, const T2& b)
  429. { a.integer /= b.integer; return a; }
  430.  
  431. T2 operator%(const T2 t, int i)
  432. { return t.integer % i; }
  433. T2 operator%(const T2 a, const T2& b)
  434. { return a.integer % b.integer; }
  435. T2& operator%=(T2& t, int i)
  436. { t.integer %= i; return t; }
  437. T2& operator%=(T2& a, const T2& b)
  438. { a.integer %= b.integer; return a; }
  439.  
  440. template<class T>
  441. class T5 {
  442. public:
  443.     T5(int);
  444.     T5(const T5<T>&);
  445.     static void* operator new(unsigned size);
  446.     static void operator delete(void *pointer);
  447.     
  448.     static T X;
  449.     T x;
  450. };
  451.  
  452. template<class T>
  453. T5<T>::T5(int)
  454. {}
  455.  
  456. template<class T>
  457. T5<T>::T5(const T5<T>&)
  458. { }
  459.  
  460. template<class T>
  461. void*
  462. T5<T>::operator new(unsigned size)
  463. { return 0; }
  464.  
  465. template<class T>
  466. void
  467. T5<T>::operator delete(void *pointer)
  468. { }
  469.  
  470. #if ! defined(__GNUC__) || defined(GCC_BUG)
  471. template<class T>
  472. T5<T>::T T5<T>::X;
  473. #endif
  474.  
  475. #ifdef GCC_TEMPLATE_BUG
  476. void
  477. useT5()
  478. {
  479. #endif
  480.     int i;
  481.     T5<char> t5c(i);
  482.     T5<int> t5i(i);
  483.     T5<int (*)(char, void *)> t5fi1(i);
  484.     T5<int (*)(int, double **, void *)> t5fi2(i);
  485.  
  486.     class x {
  487.     public:
  488.     int (*manage[5])(double,
  489.              void *(*malloc)(unsigned size),
  490.              void (*free)(void *pointer));
  491.     int (*device[5])(int open(const char *, unsigned mode, unsigned perms, int extra = 0), 
  492.              int *(*read)(int fd, void *place, unsigned size),
  493.              int *(*write)(int fd, void *place, unsigned size),
  494.              void (*close)(int fd));
  495.     };
  496.     T5<x> t5x(i);
  497. #ifdef GCC_TEMPLATE_BUG
  498. }
  499. #endif
  500.  
  501. class T7 {
  502. public:
  503.     static int get();
  504.     static void put(int);
  505. };
  506.  
  507. int
  508. T7::get()
  509. { return 1; }
  510.  
  511. void
  512. T7::put(int i)
  513. {
  514.     // nothing
  515. }
  516.  
  517. main()
  518. {
  519.     int i;
  520.  
  521.     i = i + 1;
  522. }
  523.