1# This file was written by Sue Kimura. (sue_kimura@hp.com)
2#
3# Test for CLLbs14602 -- problem with recognizing long double on 10.20.
4#
5# Source file: bs14602.c
6
7if $tracelevel {
8    strace $tracelevel
9}
10
11if { [skip_hp_tests] } { continue }
12
13#
14# test running programs
15#
16set prms_id 0
17set bug_id 0
18
19
20set testfile bs14602
21set srcfile ${testfile}.c
22set binfile ${objdir}/${subdir}/${testfile}
23
24# Create and source the file that provides information about the compiler
25# used to compile the test case.
26if [get_compiler_info ${binfile}] {
27    return -1;
28}
29
30# set up appropriate compile option to recognize long double
31if {$hp_aCC_compiler || $hp_cc_compiler} {
32    set ansi_option "-Ae"
33} else {
34    set ansi_option ""
35}
36
37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "$binfile" executable "debug {additional_flags=${ansi_option}}"] != "" } {
38    perror "Couldn't compile ${srcfile}"
39    return -1
40}
41
42
43# Start with a fresh gdb.
44
45gdb_exit
46gdb_start
47gdb_reinitialize_dir $srcdir/$subdir
48gdb_load $binfile
49
50
51# get to end of main so we can check out some stuff
52if ![runto main] {
53  perror "couldn't run to breakpoint main"
54  continue
55}
56
57gdb_test "txbreak" \
58    "Breakpoint $decimal at $hex: file .*bs14602.c, line 9." \
59    "set breakpoint at end of main"
60
61gdb_test "continue" \
62    "Continuing.\r\n$hex in main* \\(\\) at .*bs14602.c:9\r\n.*" \
63    "continue to end of main"
64
65# test some simple things about long double
66gdb_test "whatis v_long_double" \
67    "type = long double" \
68    "whatis v_long_double"
69
70gdb_test "ptype v_long_double" \
71    "type = long double" \
72    "ptype v_long_double"
73
74gdb_test "print sizeof \(long double\)" \
75    " = 16" \
76    "print sizeof long double"
77
78gdb_test "print sizeof \(v_long_double\)" \
79    " = 16" \
80    "print sizeof v_long_double"
81
82gdb_test "print v_long_double"  \
83    " = 12345.67890000000079453457146883011" \
84    "print v_long_double - 1"
85
86gdb_test "set variable v_long_double = 98765.43210" \
87    "" \
88    "set variable v_long_double to constant value"
89
90gdb_test "print v_long_double" \
91    " = 98765.43210000000544823706150054932" \
92    "print v_long_double - 2"
93
94gdb_test "set variable v_double = v_long_double" \
95    "" \
96    " set variable v_double with v_long_double"
97
98gdb_test "print v_double" \
99    " = 98765.432100000005" \
100    " print v_double"
101
102#reset v_long_double
103gdb_test "set variable v_long_double = 0" \
104    "" \
105    "reset v_long_double to 0"
106
107gdb_test "print v_long_double" \
108    " = 0" \
109    "print v_long_double - 3"
110
111gdb_test "set variable v_long_double = v_double" \
112    "" \
113    " set variable v_long_double with v_long_double"
114
115gdb_test "print v_long_double" \
116    " = 98765.43210000000544823706150054932" \
117    "print v_long_double - 4 "
118