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