1/* This testcase is part of GDB, the GNU debugger. 2 3 Copyright 2019-2023 Free Software Foundation, Inc. 4 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. 9 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. 14 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/>. */ 17 18#include <string.h> 19 20typedef struct point 21{ 22 int x; 23 int y; 24} point_t; 25 26typedef struct 27{ 28 point_t the_point; 29} struct_point_t; 30 31typedef union 32{ 33 int an_int; 34 char a_char; 35} union_t; 36 37typedef struct 38{ 39 union_t the_union; 40} struct_union_t; 41 42typedef enum 43{ 44 ENUM_FOO, 45 ENUM_BAR, 46} enum_t; 47 48typedef void (*function_t) (int); 49 50static void 51my_function(int n) 52{ 53} 54 55#ifdef __cplusplus 56 57struct Base 58{ 59 Base (int a_) : a (a_) {} 60 61 virtual int get_number () { return a; } 62 63 int a; 64 65 static int a_static_member; 66}; 67 68int Base::a_static_member = 2019; 69 70struct Deriv : Base 71{ 72 Deriv (int b_) : Base (42), b (b_) {} 73 74 virtual int get_number () { return b; } 75 76 int b; 77}; 78 79#endif 80 81int global_symbol = 42; 82 83int 84main () 85{ 86 point_t a_point_t = { 42, 12 }; 87 point_t *a_point_t_pointer = &a_point_t; 88#ifdef __cplusplus 89 point_t &a_point_t_ref = a_point_t; 90#endif 91 struct point another_point = { 123, 456 }; 92 struct_point_t a_struct_with_point = { a_point_t }; 93 94 struct_union_t a_struct_with_union; 95 /* Fill the union in an endianness-independent way. */ 96 memset (&a_struct_with_union.the_union, 42, 97 sizeof (a_struct_with_union.the_union)); 98 99 enum_t an_enum = ENUM_BAR; 100 101 const char *a_string = "hello world"; 102 const char *a_binary_string = "hello\0world"; 103 const char a_binary_string_array[] = "hello\0world"; 104 105 const int letters_repeat = 10; 106 char a_big_string[26 * letters_repeat + 1]; 107 a_big_string[26 * letters_repeat] = '\0'; 108 for (int i = 0; i < letters_repeat; i++) 109 for (char c = 'A'; c <= 'Z'; c++) 110 a_big_string[i * 26 + c - 'A'] = c; 111 112 int an_array[] = { 2, 3, 5 }; 113 114 int an_array_with_repetition[] = { 115 1, /* 1 time. */ 116 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 12 times. */ 117 5, 5, 5, /* 3 times */ 118 }; 119 120 int *a_symbol_pointer = &global_symbol; 121 122#ifdef __cplusplus 123 Deriv a_deriv (123); 124 Base &a_base_ref = a_deriv; 125#endif 126 127 return 0; /* break here */ 128} 129