1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2008-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 /* Test gdb's "return" command in reverse. */
23 char char_returnval
= '1';
24 short short_returnval
= 1;
25 int int_returnval
= 1;
26 long long_returnval
= 1;
27 long long long_long_returnval
= 1;
28 float float_returnval
= 1;
29 double double_returnval
= 1;
36 long long long_long_testval
;
38 double double_testval
;
44 void_test
= 1; /* VOID FUNC */
49 return char_returnval
; /* CHAR FUNC */
54 return short_returnval
; /* SHORT FUNC */
59 return int_returnval
; /* INT FUNC */
64 return long_returnval
; /* LONG FUNC */
67 long long long_long_func ()
69 return long_long_returnval
; /* LONG LONG FUNC */
74 return float_returnval
; /* FLOAT FUNC */
79 return double_returnval
; /* DOUBLE FUNC */
82 int main (int argc
, char **argv
)
85 short short_resultval
;
88 long long long_long_resultval
;
89 float float_resultval
;
90 double double_resultval
;
93 /* A "test load" that will insure that the function really returns
94 a ${type} (as opposed to just a truncated or part of a ${type}). */
95 for (i
= 0; i
< sizeof (testval
.ffff
); i
++)
96 testval
.ffff
[i
] = 0xff;
98 void_func (); /* call to void_func */
99 char_resultval
= char_func (); /* void_checkpoint */
100 short_resultval
= short_func (); /* char_checkpoint */
101 int_resultval
= int_func (); /* short_checkpoint */
102 long_resultval
= long_func (); /* int_checkpoint */
103 long_long_resultval
= long_long_func (); /* long_checkpoint */
105 /* On machines using IEEE floating point, the test pattern of all
106 1-bits established above turns out to be a floating-point NaN
107 ("Not a Number"). According to the IEEE rules, NaN's aren't even
108 equal to themselves. This can lead to stupid conversations with
111 (gdb) p testval.float_testval == testval.float_testval
115 This is the correct answer, but it's not the sort of thing
116 return2.exp wants to see. So to make things work the way they
117 ought, we'll set aside the `union' cleverness and initialize the
118 test values explicitly here. These values have interesting bits
119 throughout the value, so we'll still detect truncated values. */
121 testval
.float_testval
= 2.7182818284590452354;/* long_long_checkpoint */
122 float_resultval
= float_func ();
123 testval
.double_testval
= 3.14159265358979323846; /* float_checkpoint */
124 double_resultval
= double_func ();
125 main_test
= 1; /* double_checkpoint */
This page took 0.032995 seconds and 4 git commands to generate.