1# Copyright (C) 2001-2016 Free Software Foundation, Inc. 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 3 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License for more details. 12# 13# You should have received a copy of the GNU General Public License 14# along with this program. If not, see <http://www.gnu.org/licenses/>. 15 16# Written by Michael Snyder, Red Hat, Inc., 9/20/2001 17 18# This file is part of the gdb testsuite 19# Tests for type expressions using the new "@code" and "@data" modifiers. 20 21# 22# test running programs 23# 24 25standard_testfile cvexpr.c 26 27if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { 28 untested code-expr.exp 29 return -1 30} 31 32clean_restart ${binfile} 33 34gdb_test_no_output "set print sevenbit-strings" 35gdb_test_no_output "set print address off" 36gdb_test_no_output "set width 0" 37 38set ws "\[ \t\]*" 39 40# 41# Test casting a scalar to const 42# 43 44gdb_test "whatis (@code char) v_char" \ 45 "type = @code char" \ 46 "(@code char)" 47gdb_test "whatis (@code signed char) v_signed_char" \ 48 "type = @code signed char" \ 49 "(@code signed char)" 50gdb_test "whatis (@code unsigned char) v_unsigned_char" \ 51 "type = @code (unsigned char|char)" \ 52 "(@code unsigned char)" 53gdb_test "whatis (@code short) v_short" \ 54 "type = @code (short|short int)" \ 55 "(@code short)" 56gdb_test "whatis (@code signed short) v_signed_short" \ 57 "type = @code (short|short int|signed short|signed short int)" \ 58 "(@code signed short)" 59gdb_test "whatis (@code unsigned short) v_unsigned_short" \ 60 "type = @code (unsigned short|short unsigned int)" \ 61 "(@code unsigned short)" 62gdb_test "whatis (@code int) v_int" \ 63 "type = @code int" \ 64 "(@code int)" 65gdb_test "whatis (@code signed int) v_signed_int" \ 66 "type = @code (signed int|int)" \ 67 "(@code signed int)" 68gdb_test "whatis (@code unsigned int) v_unsigned_int" \ 69 "type = @code unsigned int" \ 70 "(@code unsigned int)" 71gdb_test "whatis (@code long) v_long" \ 72 "type = @code (long|long int)" \ 73 "(@code long)" 74gdb_test "whatis (@code signed long) v_signed_long" \ 75 "type = @code (signed |)long( int|)" \ 76 "(@code signed long)" 77gdb_test "whatis (@code unsigned long) v_unsigned_long" \ 78 "type = @code (unsigned long|long unsigned int)" \ 79 "(@code unsigned long)" 80gdb_test "whatis (@code long long) v_long_long" \ 81 "type = @code long long( int|)" \ 82 "(@code long long)" 83gdb_test "whatis (@code signed long long) v_signed_long_long" \ 84 "type = @code (signed |)long long( int|)" \ 85 "(@code signed long long)" 86gdb_test "whatis (@code unsigned long long) v_unsigned_long_long" \ 87 "type = @code (unsigned long long|long long unsigned int)" \ 88 "(@code unsigned long long)" 89gdb_test "whatis (@code float) v_float" \ 90 "type = @code float" \ 91 "(@code float)" 92gdb_test "whatis (@code double) v_double" \ 93 "type = @code double" \ 94 "(@code double)" 95 96# 97# Test casting a scalar to @data 98# 99 100gdb_test "whatis (@data char) v_char" \ 101 "type = @data char" \ 102 "(@data char)" 103gdb_test "whatis (@data signed char) v_signed_char" \ 104 "type = @data signed char" \ 105 "(@data signed char)" 106gdb_test "whatis (@data unsigned char) v_unsigned_char" \ 107 "type = @data (unsigned char|char)" \ 108 "(@data unsigned char)" 109gdb_test "whatis (@data short) v_short" \ 110 "type = @data (short|short int)" \ 111 "(@data short)" 112gdb_test "whatis (@data signed short) v_signed_short" \ 113 "type = @data (short|short int|signed short|signed short int)" \ 114 "(@data signed short)" 115gdb_test "whatis (@data unsigned short) v_unsigned_short" \ 116 "type = @data (unsigned short|short unsigned int)" \ 117 "(@data unsigned short)" 118gdb_test "whatis (@data int) v_int" \ 119 "type = @data int" \ 120 "(@data int)" 121gdb_test "whatis (@data signed int) v_signed_int" \ 122 "type = @data (signed int|int)" \ 123 "(@data signed int)" 124gdb_test "whatis (@data unsigned int) v_unsigned_int" \ 125 "type = @data unsigned int" \ 126 "(@data unsigned int)" 127gdb_test "whatis (@data long) v_long" \ 128 "type = @data (long|long int)" \ 129 "(@data long)" 130gdb_test "whatis (@data signed long) v_signed_long" \ 131 "type = @data (signed |)long( int|)" \ 132 "(@data signed long)" 133gdb_test "whatis (@data unsigned long) v_unsigned_long" \ 134 "type = @data (unsigned long|long unsigned int)" \ 135 "(@data unsigned long)" 136gdb_test "whatis (@data long long) v_long_long" \ 137 "type = @data long long( int|)" \ 138 "(@data long long)" 139gdb_test "whatis (@data signed long long) v_signed_long_long" \ 140 "type = @data (signed |)long long( int|)" \ 141 "(@data signed long long)" 142gdb_test "whatis (@data unsigned long long) v_unsigned_long_long" \ 143 "type = @data (unsigned long long|long long unsigned int)" \ 144 "(@data unsigned long long)" 145gdb_test "whatis (@data float) v_float" \ 146 "type = @data float" \ 147 "(@data float)" 148gdb_test "whatis (@data double) v_double" \ 149 "type = @data double" \ 150 "(@data double)" 151 152# 153# Now put the '@code' and '@data' keywords after the base type. 154# 155 156gdb_test "whatis (char @code) v_char" \ 157 "type = @code char" \ 158 "(char @code)" 159gdb_test "whatis (signed char @code) v_signed_char" \ 160 "type = @code signed char" \ 161 "(signed char @code)" 162gdb_test "whatis (unsigned char @code) v_unsigned_char" \ 163 "type = @code (unsigned char|char)" \ 164 "(unsigned char @code)" 165gdb_test "whatis (short @code) v_short" \ 166 "type = @code (short|short int)" \ 167 "(short @code)" 168gdb_test "whatis (signed short @code) v_signed_short" \ 169 "type = @code (short|short int|signed short|signed short int)" \ 170 "(signed short @code)" 171gdb_test "whatis (unsigned short @code) v_unsigned_short" \ 172 "type = @code (unsigned short|short unsigned int)" \ 173 "(unsigned short @code)" 174gdb_test "whatis (int @code) v_int" \ 175 "type = @code int" \ 176 "(int @code)" 177gdb_test "whatis (signed int @code) v_signed_int" \ 178 "type = @code (signed int|int)" \ 179 "(signed int @code)" 180gdb_test "whatis (unsigned int @code) v_unsigned_int" \ 181 "type = @code unsigned int" \ 182 "(unsigned int @code)" 183gdb_test "whatis (long @code) v_long" \ 184 "type = @code (long|long int)" \ 185 "(long @code)" 186gdb_test "whatis (signed long @code) v_signed_long" \ 187 "type = @code (signed |)long( int|)" \ 188 "(signed long @code)" 189gdb_test "whatis (unsigned long @code) v_unsigned_long" \ 190 "type = @code (unsigned long|long unsigned int)" \ 191 "(unsigned long @code)" 192gdb_test "whatis (long long @code) v_long_long" \ 193 "type = @code long long( int|)" \ 194 "(long long @code)" 195gdb_test "whatis (signed long long @code) v_signed_long_long" \ 196 "type = @code (signed |)long long( int|)" \ 197 "(signed long long @code)" 198gdb_test "whatis (unsigned long long @code) v_unsigned_long_long" \ 199 "type = @code (unsigned long long|long long unsigned int)" \ 200 "(unsigned long long @code)" 201gdb_test "whatis (float @code) v_float" \ 202 "type = @code float" \ 203 "(float @code)" 204gdb_test "whatis (double @code) v_double" \ 205 "type = @code double" \ 206 "(double @code)" 207 208gdb_test "whatis (char @data) v_char" \ 209 "type = @data char" \ 210 "(char @data)" 211gdb_test "whatis (signed char @data) v_signed_char" \ 212 "type = @data signed char" \ 213 "(signed char @data)" 214gdb_test "whatis (unsigned char @data) v_unsigned_char" \ 215 "type = @data (unsigned char|char)" \ 216 "(unsigned char @data)" 217gdb_test "whatis (short @data) v_short" \ 218 "type = @data (short|short int)" \ 219 "(short @data)" 220gdb_test "whatis (signed short @data) v_signed_short" \ 221 "type = @data (short|short int|signed short|signed short int)" \ 222 "(signed short @data)" 223gdb_test "whatis (unsigned short @data) v_unsigned_short" \ 224 "type = @data (unsigned short|short unsigned int)" \ 225 "(unsigned short @data)" 226gdb_test "whatis (int @data) v_int" \ 227 "type = @data int" \ 228 "(int @data)" 229gdb_test "whatis (signed int @data) v_signed_int" \ 230 "type = @data (signed int|int)" \ 231 "(signed int @data)" 232gdb_test "whatis (unsigned int @data) v_unsigned_int" \ 233 "type = @data unsigned int" \ 234 "(unsigned int @data)" 235gdb_test "whatis (long @data) v_long" \ 236 "type = @data (long|long int)" \ 237 "(long @data)" 238gdb_test "whatis (signed long @data) v_signed_long" \ 239 "type = @data (signed |)long( int|)" \ 240 "(signed long @data)" 241gdb_test "whatis (unsigned long @data) v_unsigned_long" \ 242 "type = @data (unsigned long|long unsigned int)" \ 243 "(unsigned long @data)" 244gdb_test "whatis (long long @data) v_long_long" \ 245 "type = @data long long( int|)" \ 246 "(long long @data)" 247gdb_test "whatis (signed long long @data) v_signed_long_long" \ 248 "type = @data (signed |)long long( int|)" \ 249 "(signed long long @data)" 250gdb_test "whatis (unsigned long long @data) v_unsigned_long_long" \ 251 "type = @data (unsigned long long|long long unsigned int)" \ 252 "(unsigned long long @data)" 253gdb_test "whatis (float @data) v_float" \ 254 "type = @data float" \ 255 "(float @data)" 256gdb_test "whatis (double @data) v_double" \ 257 "type = @data double" \ 258 "(double @data)" 259 260# 261# enums 262# 263 264gdb_test "whatis (@code enum misordered) v_misordered" \ 265 "type = @code enum misordered" \ 266 "(@code enum misordered)" 267gdb_test "whatis (enum misordered @code) v_misordered" \ 268 "type = @code enum misordered" \ 269 "(enum misordered @code)" 270gdb_test "whatis (@data enum misordered) v_misordered" \ 271 "type = @data enum misordered" \ 272 "(@data enum misordered)" 273gdb_test "whatis (enum misordered @data) v_misordered" \ 274 "type = @data enum misordered" \ 275 "(enum misordered @data)" 276 277# 278# Pointers 279# 280 281gdb_test "whatis (@code int *) v_int_pointer" \ 282 "type = @code int${ws}\\*" \ 283 "(@code int *)" 284gdb_test "whatis (int @code *) v_int_pointer" \ 285 "type = @code int${ws}\\*" \ 286 "(int @code *)" 287gdb_test "whatis (int * @code) v_int_pointer" \ 288 "type = int \\*${ws}@code" \ 289 "(int * @code)" 290gdb_test "whatis (@code int * @code) v_int_pointer" \ 291 "type = @code int${ws}\\*${ws}@code" \ 292 "(@code int * @code)" 293gdb_test "whatis (int @code * @code) v_int_pointer" \ 294 "type = @code int${ws}\\*${ws}@code" \ 295 "(int @code * @code)" 296 297gdb_test "whatis (@code int **) v_int_pointer_pointer" \ 298 "type = @code int${ws}\\*${ws}\\*" \ 299 "(@code int **)" 300gdb_test "whatis (int @code **) v_int_pointer_pointer" \ 301 "type = @code int${ws}\\*${ws}\\*" \ 302 "(int @code **)" 303gdb_test "whatis (int ** @code) v_int_pointer_pointer" \ 304 "type = int \\*${ws}\\*${ws}@code" \ 305 "(int ** @code)" 306gdb_test "whatis (@code int * @code *) v_int_pointer_pointer" \ 307 "type = @code int${ws}\\*${ws}@code${ws}\\*" \ 308 "(@code int * @code *)" 309gdb_test "whatis (int @code * @code *) v_int_pointer_pointer" \ 310 "type = @code int${ws}\\*${ws}@code${ws}\\*" \ 311 "(int @code * @code *)" 312gdb_test "whatis (@code int * @code * @code) v_int_pointer_pointer" \ 313 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \ 314 "(@code int * @code * @code)" 315gdb_test "whatis (int @code * @code * @code) v_int_pointer_pointer" \ 316 "type = @code int${ws}\\*${ws}@code${ws}\\*${ws}@code" \ 317 "(int @code * @code * @code)" 318 319# 320# Arrays TODO 321# 322 323# 324# Pointers to arrays, arrays of pointers TODO 325# 326 327# 328# Structs and Unions 329# 330 331gdb_test "whatis (@code struct t_struct) v_struct1" \ 332 "type = @code struct t_struct" \ 333 "(@code struct t_struct)" 334gdb_test "whatis (@code union t_union) v_union" \ 335 "type = @code union t_union" \ 336 "(@code union t_union)" 337gdb_test "whatis (struct t_struct @code) v_struct1" \ 338 "type = @code struct t_struct" \ 339 "(struct t_struct @code)" 340gdb_test "whatis (union t_union @code) v_union" \ 341 "type = @code union t_union" \ 342 "(union t_union @code)" 343gdb_test "whatis (@code struct t_struct *) &v_struct1" \ 344 "type = @code struct t_struct${ws}\\*" \ 345 "(@code struct t_struct *)" 346gdb_test "whatis (@code union t_union *) &v_union" \ 347 "type = @code union t_union${ws}\\*" \ 348 "(@code union t_union *)" 349gdb_test "whatis (struct t_struct @code *) &v_struct1" \ 350 "type = @code struct t_struct${ws}\\*" \ 351 "(struct t_struct @code *)" 352gdb_test "whatis (union t_union @code *) &v_union" \ 353 "type = @code union t_union${ws}\\*" \ 354 "(union t_union @code *)" 355gdb_test "whatis (struct t_struct * @code) &v_struct1" \ 356 "type = struct t_struct${ws}\\*${ws}@code" \ 357 "(struct t_struct * @code)" 358gdb_test "whatis (union t_union * @code) &v_union" \ 359 "type = union t_union${ws}\\*${ws}@code" \ 360 "(union t_union * @code)" 361gdb_test "whatis (@code struct t_struct * @code) &v_struct1" \ 362 "type = @code struct t_struct${ws}\\*${ws}@code" \ 363 "(@code struct t_struct * @code)" 364gdb_test "whatis (@code union t_union * @code) &v_union" \ 365 "type = @code union t_union${ws}\\*${ws}@code" \ 366 "(@code union t_union * @code)" 367gdb_test "whatis (struct t_struct @code * @code) &v_struct1" \ 368 "type = @code struct t_struct${ws}\\*${ws}@code" \ 369 "(struct t_struct @code * @code)" 370gdb_test "whatis (union t_union @code * @code) &v_union" \ 371 "type = @code union t_union${ws}\\*${ws}@code" \ 372 "(union t_union @code * @code)" 373 374# 375# Function pointers TODO 376# 377 378