gdb.python/py-nested-maps.exp C++ify

This adjusts gdb.python/py-nested-maps.c to make it buildable as C++ program.

key_t is renamed because of:

  src/gdb/testsuite/gdb.python/py-nested-maps.c:23:8: error: definition of type 'key_t' conflicts with typedef of the same name
  struct key_t
	 ^
  /usr/include/x86_64-linux-gnu/sys/types.h:121:17: note: 'key_t' declared here
  typedef __key_t key_t;
		  ^

gdb/testsuite/ChangeLog:

	* gdb.python/py-nested-maps.c (struct key_t): Rename to...
	(struct my_key_t): ... this.  Adjust all references.
	(struct value_t): Rename to ...
	(struct my_value_t): ... this.  Adjust all references.
	(create_map, add_map_element, create_map_map)
	(add_map_map_element): Add casts.
This commit is contained in:
Pedro Alves 2020-09-17 23:33:42 +01:00
parent d4bcee5ccc
commit a83cdcb636
2 changed files with 31 additions and 22 deletions

View File

@ -1,3 +1,12 @@
2020-09-17 Pedro Alves <pedro@palves.net>
* gdb.python/py-nested-maps.c (struct key_t): Rename to...
(struct my_key_t): ... this. Adjust all references.
(struct value_t): Rename to ...
(struct my_value_t): ... this. Adjust all references.
(create_map, add_map_element, create_map_map)
(add_map_map_element): Add casts.
2020-09-17 Pedro Alves <pedro@palves.net>
* gdb.python/py-framefilter-mi.c (funca): Add casts.

View File

@ -20,13 +20,13 @@
#define FIXED_MAP_SIZE 10
struct key_t
struct my_key_t
{
int a;
int b;
};
struct value_t
struct my_value_t
{
int x;
int y;
@ -37,8 +37,8 @@ struct map_t
{
const char *name;
int length;
struct key_t *keys;
struct value_t *values;
struct my_key_t *keys;
struct my_value_t *values;
/* This field is used only by the pretty printer. */
int show_header;
@ -56,7 +56,7 @@ struct map_map_t
struct map_t *
create_map (const char *name)
{
struct map_t *m = malloc (sizeof (struct map_t));
struct map_t *m = (struct map_t *) malloc (sizeof (struct map_t));
m->name = strdup (name);
m->length = 0;
m->keys = NULL;
@ -66,12 +66,12 @@ create_map (const char *name)
}
void
add_map_element (struct map_t *m, struct key_t k, struct value_t v)
add_map_element (struct map_t *m, struct my_key_t k, struct my_value_t v)
{
if (m->length == 0)
{
m->keys = malloc (sizeof (struct key_t) * FIXED_MAP_SIZE);
m->values = malloc (sizeof (struct value_t) * FIXED_MAP_SIZE);
m->keys = (struct my_key_t *) malloc (sizeof (struct my_key_t) * FIXED_MAP_SIZE);
m->values = (struct my_value_t *) malloc (sizeof (struct my_value_t) * FIXED_MAP_SIZE);
}
m->keys[m->length] = k;
@ -82,7 +82,7 @@ add_map_element (struct map_t *m, struct key_t k, struct value_t v)
struct map_map_t *
create_map_map (void)
{
struct map_map_t *mm = malloc (sizeof (struct map_map_t));
struct map_map_t *mm = (struct map_map_t *) malloc (sizeof (struct map_map_t));
mm->length = 0;
mm->values = NULL;
mm->show_header = 0;
@ -93,7 +93,7 @@ void
add_map_map_element (struct map_map_t *mm, struct map_t *map)
{
if (mm->length == 0)
mm->values = malloc (sizeof (struct map_t *) * FIXED_MAP_SIZE);
mm->values = (struct map_t **) malloc (sizeof (struct map_t *) * FIXED_MAP_SIZE);
mm->values[mm->length] = map;
mm->length++;
@ -103,18 +103,18 @@ int
main (void)
{
struct map_t *m1 = create_map ("m1");
struct key_t k1 = {3, 4};
struct key_t k2 = {4, 5};
struct key_t k3 = {5, 6};
struct key_t k4 = {6, 7};
struct key_t k5 = {7, 8};
struct key_t k6 = {8, 9};
struct value_t v1 = {0, 1, 2};
struct value_t v2 = {3, 4, 5};
struct value_t v3 = {6, 7, 8};
struct value_t v4 = {9, 0, 1};
struct value_t v5 = {2, 3, 4};
struct value_t v6 = {5, 6, 7};
struct my_key_t k1 = {3, 4};
struct my_key_t k2 = {4, 5};
struct my_key_t k3 = {5, 6};
struct my_key_t k4 = {6, 7};
struct my_key_t k5 = {7, 8};
struct my_key_t k6 = {8, 9};
struct my_value_t v1 = {0, 1, 2};
struct my_value_t v2 = {3, 4, 5};
struct my_value_t v3 = {6, 7, 8};
struct my_value_t v4 = {9, 0, 1};
struct my_value_t v5 = {2, 3, 4};
struct my_value_t v6 = {5, 6, 7};
add_map_element (m1, k1, v1);
add_map_element (m1, k2, v2);
add_map_element (m1, k3, v3);