1 /* Test gdb's "return" command. */
6 char char_returnval
= '1';
7 short short_returnval
= 1;
9 long long_returnval
= 1;
10 long long long_long_returnval
= 1;
11 float float_returnval
= 1;
12 double double_returnval
= 1;
19 long long long_long_testval
;
21 double double_testval
;
32 return char_returnval
;
37 return short_returnval
;
47 return long_returnval
;
50 long long long_long_func ()
52 return long_long_returnval
;
57 return float_returnval
;
62 return double_returnval
;
65 int main (int argc
, char **argv
)
68 short short_resultval
;
71 long long long_long_resultval
;
72 float float_resultval
;
73 double double_resultval
;
76 /* A "test load" that will insure that the function really returns
77 a ${type} (as opposed to just a truncated or part of a ${type}). */
78 for (i
= 0; i
< sizeof (testval
.ffff
); i
++)
79 testval
.ffff
[i
] = 0xff;
81 void_func (); /* call to void_func */
82 char_resultval
= char_func (); /* void_checkpoint */
83 short_resultval
= short_func (); /* char_checkpoint */
84 int_resultval
= int_func (); /* short_checkpoint */
85 long_resultval
= long_func (); /* int_checkpoint */
86 long_long_resultval
= long_long_func (); /* long_checkpoint */
88 /* On machines using IEEE floating point, the test pattern of all
89 1-bits established above turns out to be a floating-point NaN
90 ("Not a Number"). According to the IEEE rules, NaN's aren't even
91 equal to themselves. This can lead to stupid conversations with
94 (gdb) p testval.float_testval == testval.float_testval
98 This is the correct answer, but it's not the sort of thing
99 return2.exp wants to see. So to make things work the way they
100 ought, we'll set aside the `union' cleverness and initialize the
101 test values explicitly here. These values have interesting bits
102 throughout the value, so we'll still detect truncated values. */
104 testval
.float_testval
= 2.7182818284590452354;/* long_long_checkpoint */
105 float_resultval
= float_func ();
106 testval
.double_testval
= 3.14159265358979323846; /* float_checkpoint */
107 double_resultval
= double_func ();
108 main_test
= 1; /* double_checkpoint */