From 1c6fbf42e5bd3045a41ad32c5efbc2ab8ca5e941 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 29 Apr 2022 23:21:18 +0100 Subject: 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 --- gdb/rust-lang.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gdb/rust-lang.c') diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index bf8dba9..746f565 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -669,7 +669,7 @@ rust_print_struct_def (struct type *type, const char *varstring, /* If we see a base class, delegate to C. */ if (TYPE_N_BASECLASSES (type) > 0) - c_print_type (type, varstring, stream, show, level, flags); + c_print_type (type, varstring, stream, show, level, language_rust, flags); if (flags->print_offsets) { @@ -922,7 +922,8 @@ rust_internal_print_type (struct type *type, const char *varstring, default: c_printer: - c_print_type (type, varstring, stream, show, level, flags); + c_print_type (type, varstring, stream, show, level, language_rust, + flags); } } -- cgit v1.1