aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-04-29 23:21:18 +0100
committerPedro Alves <pedro@palves.net>2022-05-10 14:16:21 +0100
commit1c6fbf42e5bd3045a41ad32c5efbc2ab8ca5e941 (patch)
treede24937c9c0144720c3fcd4414b0028f0c0bce7b /gdb/c-exp.y
parentcb2cd8cba82a0a5480a147d95b16098ad74d33c6 (diff)
downloadgdb-1c6fbf42e5bd3045a41ad32c5efbc2ab8ca5e941.zip
gdb-1c6fbf42e5bd3045a41ad32c5efbc2ab8ca5e941.tar.gz
gdb-1c6fbf42e5bd3045a41ad32c5efbc2ab8ca5e941.tar.bz2
Always pass an explicit language down to c_type_print
The next patch will want to do language->print_type(type, ...), to print a type in a given language, avoiding a dependency on the current language. That doesn't work correctly currently, however, because most language implementations of language_defn::print_type call c_print_type without passing down the language. There are two overloads of c_print_type, one that takes a language, and one that does not. The one that does not uses the current language, defeating the point of calling language->print_type()... This commit removes the c_print_type overload that does not take a language, and adjusts the codebase throughout to always pass down a language. In most places, there's already an enum language handy. language_defn::print_type implementations naturally pass down this->la_language. In a couple spots, like in ada-typeprint.c and rust-lang.c there's no enum language handy, but the code is written for a specific language, so we just hardcode the language. In gnuv3_print_method_ptr, I wasn't sure whether we could hardcode C++ here, and we don't have an enum language handy, so I made it use the current language, just like today. Can always be improved later. Change-Id: Ib54fab4cf0fd307bfd55bf1dd5056830096a653b
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y1
1 files changed, 1 insertions, 0 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 517ab42..72f8dd3 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1783,6 +1783,7 @@ oper: OPERATOR NEW
{
string_file buf;
c_print_type ($2, NULL, &buf, -1, 0,
+ pstate->language ()->la_language,
&type_print_raw_options);
std::string name = buf.release ();