[pushed/ob] [C++] Add casts to obstack_base calls

Pedro Alves
2015-11-18T16:01:33Z

From: Simon Marchi <simon.marchi@ericsson.com>

The recent libiberty import of upstream obstack.h (314dee8ea9be) makes
obstack_base return a 'void *', with the consequence that a few places
in gdb need a (char *) cast.

gdb/ChangeLog:
2015-11-18 Simon Marchi <simon.marchi@ericsson.com>
Pedro Alves <palves@redhat.com>

* break-catch-sig.c (signal_catchpoint_print_one): Add cast.
* c-exp.y (parse_string_or_char, yylex): Add casts.
* c-lang.c (evaluate_subexp_c): Add casts.
* d-exp.y (parse_string_or_char, yylex): Add casts.
* go-exp.y (parse_string_or_char, build_packaged_name): Add casts.
* p-valprint.c (pascal_object_print_value_fields): Add casts.
* valprint.c (generic_emit_char, generic_printstr): Add casts.
---
gdb/ChangeLog | 11 +++++++++++
gdb/break-catch-sig.c | 2 +-
gdb/c-exp.y | 4 ++--
gdb/c-lang.c | 2 +-
gdb/d-exp.y | 6 +++---
gdb/go-exp.y | 4 ++--
gdb/p-valprint.c | 3 ++-
gdb/valprint.c | 4 ++--
8 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 32f8134..d92ba43 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,4 +1,15 @@
2015-11-18 Simon Marchi <simon.marchi@ericsson.com>
+ Pedro Alves <palves@redhat.com>
+
+ * break-catch-sig.c (signal_catchpoint_print_one): Add cast.
+ * c-exp.y (parse_string_or_char, yylex): Add casts.
+ * c-lang.c (evaluate_subexp_c): Add casts.
+ * d-exp.y (parse_string_or_char, yylex): Add casts.
+ * go-exp.y (parse_string_or_char, build_packaged_name): Add casts.
+ * p-valprint.c (pascal_object_print_value_fields): Add casts.
+ * valprint.c (generic_emit_char, generic_printstr): Add casts.
+
+2015-11-18 Simon Marchi <simon.marchi@ericsson.com>

* valops.c (value_cstring): Constify 'ptr' parameter.
* value.h (value_cstring): Constify 'ptr' parameter.
diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index f117bd5..158ce03 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -279,7 +279,7 @@ signal_catchpoint_print_one (struct breakpoint *b,
obstack_grow (&text, name, strlen (name));
}
obstack_grow (&text, "", 1);
- ui_out_field_string (uiout, "what", obstack_base (&text));
+ ui_out_field_string (uiout, "what", (const char *) obstack_base (&text));
do_cleanups (cleanup);
}
else
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 9127756..030e818 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2247,7 +2247,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
++tokptr;

value->type = type;
- value->ptr = obstack_base (&tempbuf);
+ value->ptr = (char *) obstack_base (&tempbuf);
value->length = obstack_object_size (&tempbuf);

*outptr = tokptr;
@@ -3173,7 +3173,7 @@ yylex (void)
obstack_grow (&name_obstack, next->value.sval.ptr,
next->value.sval.length);

- yylval.sval.ptr = obstack_base (&name_obstack);
+ yylval.sval.ptr = (const char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
current.value = yylval;
current.token = classification;
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 2646b05..d79a827 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -701,7 +701,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
obstack_object_size (&output));
}
else
- result = value_cstring (obstack_base (&output),
+ result = value_cstring ((const char *) obstack_base (&output),
obstack_object_size (&output),
type);
}
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 0481b14..fb955ba 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -1005,7 +1005,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
else
value->type = C_STRING;

- value->ptr = obstack_base (&tempbuf);
+ value->ptr = (char *) obstack_base (&tempbuf);
value->length = obstack_object_size (&tempbuf);

*outptr = tokptr;
@@ -1558,7 +1558,7 @@ yylex (void)
obstack_grow (&name_obstack, next->value.sval.ptr,
next->value.sval.length);

- yylval.sval.ptr = obstack_base (&name_obstack);
+ yylval.sval.ptr = (char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);

current.token = classify_name (pstate, expression_context_block);
@@ -1638,7 +1638,7 @@ yylex (void)
obstack_grow (&name_obstack, next->value.sval.ptr,
next->value.sval.length);

- yylval.sval.ptr = obstack_base (&name_obstack);
+ yylval.sval.ptr = (char *) obstack_base (&name_obstack);
yylval.sval.length = obstack_object_size (&name_obstack);
current.value = yylval;
current.token = classification;
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index c2ae28d..2cbc2c1 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -975,7 +975,7 @@ parse_string_or_char (const char *tokptr, const char **outptr,
++tokptr;

value->type = C_STRING | (quote == '\'' ? C_CHAR : 0); /*FIXME*/
- value->ptr = obstack_base (&tempbuf);
+ value->ptr = (char *) obstack_base (&tempbuf);
value->length = obstack_object_size (&tempbuf);

*outptr = tokptr;
@@ -1363,7 +1363,7 @@ build_packaged_name (const char *package, int package_len,
obstack_grow_str (&name_obstack, ".");
obstack_grow (&name_obstack, name, name_len);
obstack_grow (&name_obstack, "", 1);
- result.ptr = obstack_base (&name_obstack);
+ result.ptr = (char *) obstack_base (&name_obstack);
result.length = obstack_object_size (&name_obstack) - 1;

return result;
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 120035a..4c307de 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -535,7 +535,8 @@ pascal_object_print_value_fields (struct type *type, const gdb_byte *valaddr,
int dont_print_statmem)
{
int i, len, n_baseclasses;
- char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
+ char *last_dont_print
+ = (char *) obstack_next_free (&dont_print_statmem_obstack);

type = check_typedef (type);

diff --git a/gdb/valprint.c b/gdb/valprint.c
index 7f891c9..753c2a1 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -2362,7 +2362,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
sizeof (gdb_wchar_t), &output, translit_char);
obstack_1grow (&output, '\0');

- fputs_filtered (obstack_base (&output), stream);
+ fputs_filtered ((const char *) obstack_base (&output), stream);

do_cleanups (cleanups);
}
@@ -2717,7 +2717,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
sizeof (gdb_wchar_t), &output, translit_char);
obstack_1grow (&output, '\0');

- fputs_filtered (obstack_base (&output), stream);
+ fputs_filtered ((const char *) obstack_base (&output), stream);

do_cleanups (cleanup);
}
--
1.9.3