Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.python / py-format-string.c
blobcc251f6aafec48f624bd90546c3dfd4fe4fee94f
1 /* This testcase is part of GDB, the GNU debugger.
3 Copyright 2019-2022 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 #include <string.h>
20 typedef struct point
22 int x;
23 int y;
24 } point_t;
26 typedef struct
28 point_t the_point;
29 } struct_point_t;
31 typedef union
33 int an_int;
34 char a_char;
35 } union_t;
37 typedef struct
39 union_t the_union;
40 } struct_union_t;
42 typedef enum
44 ENUM_FOO,
45 ENUM_BAR,
46 } enum_t;
48 typedef void (*function_t) (int);
50 static void
51 my_function(int n)
55 #ifdef __cplusplus
57 struct Base
59 Base (int a_) : a (a_) {}
61 virtual int get_number () { return a; }
63 int a;
65 static int a_static_member;
68 int Base::a_static_member = 2019;
70 struct Deriv : Base
72 Deriv (int b_) : Base (42), b (b_) {}
74 virtual int get_number () { return b; }
76 int b;
79 #endif
81 int global_symbol = 42;
83 int
84 main ()
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 };
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));
99 enum_t an_enum = ENUM_BAR;
101 const char *a_string = "hello world";
102 const char *a_binary_string = "hello\0world";
103 const char a_binary_string_array[] = "hello\0world";
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;
112 int an_array[] = { 2, 3, 5 };
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 */
120 int *a_symbol_pointer = &global_symbol;
122 #ifdef __cplusplus
123 Deriv a_deriv (123);
124 Base &a_base_ref = a_deriv;
125 #endif
127 return 0; /* break here */