diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index dca96231117..7e9d941a435 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -441,31 +441,6 @@ c_type_print_varspec_prefix (struct type *type, stream, show, passed_a_ptr, 0, language, flags, podata); break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLAGS: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_CHAR: - case TYPE_CODE_BOOL: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_STRING: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_NAMESPACE: - case TYPE_CODE_DECFLOAT: - case TYPE_CODE_FIXED_POINT: - /* These types need no prefix. They are listed here so that - gcc -Wall will reveal any types that haven't been handled. */ - break; - default: - error (_("type not handled in c_type_print_varspec_prefix()")); - break; } } @@ -821,32 +796,6 @@ c_type_print_varspec_suffix (struct type *type, c_type_print_varspec_suffix (type->target_type (), stream, show, passed_a_ptr, 0, language, flags); break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_FLAGS: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_CHAR: - case TYPE_CODE_BOOL: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_STRING: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_NAMESPACE: - case TYPE_CODE_DECFLOAT: - case TYPE_CODE_FIXED_POINT: - /* These types do not need a suffix. They are listed so that - gcc -Wall will report types that may not have been - considered. */ - break; - default: - error (_("type not handled in c_type_print_varspec_suffix()")); - break; } } diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index e8542d6845a..7458aa6c095 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -244,29 +244,6 @@ pascal_language::type_print_varspec_prefix (struct type *type, plongest (type->bounds ()->high.const_val ())); gdb_printf (stream, "of "); break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_CHAR: - case TYPE_CODE_BOOL: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_STRING: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_TYPEDEF: - case TYPE_CODE_FIXED_POINT: - /* These types need no prefix. They are listed here so that - gcc -Wall will reveal any types that haven't been handled. */ - break; - default: - gdb_assert_not_reached ("unexpected type"); - break; } } @@ -377,29 +354,6 @@ pascal_language::type_print_varspec_suffix (struct type *type, type_print_func_varspec_suffix (type, stream, show, passed_a_ptr, 0, flags); break; - - case TYPE_CODE_UNDEF: - case TYPE_CODE_STRUCT: - case TYPE_CODE_UNION: - case TYPE_CODE_ENUM: - case TYPE_CODE_INT: - case TYPE_CODE_FLT: - case TYPE_CODE_VOID: - case TYPE_CODE_ERROR: - case TYPE_CODE_CHAR: - case TYPE_CODE_BOOL: - case TYPE_CODE_SET: - case TYPE_CODE_RANGE: - case TYPE_CODE_STRING: - case TYPE_CODE_COMPLEX: - case TYPE_CODE_TYPEDEF: - case TYPE_CODE_FIXED_POINT: - /* These types do not need a suffix. They are listed so that - gcc -Wall will report types that may not have been considered. */ - break; - default: - gdb_assert_not_reached ("unexpected type"); - break; } } diff --git a/gdb/testsuite/gdb.base/internal-functions-ptype.exp b/gdb/testsuite/gdb.base/internal-functions-ptype.exp new file mode 100644 index 00000000000..42caae05aad --- /dev/null +++ b/gdb/testsuite/gdb.base/internal-functions-ptype.exp @@ -0,0 +1,42 @@ +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test "ptype INTERNAL_FUNCTION" in all languages. + +proc test_ptype_internal_function {} { + set all_languages [get_set_option_choices "set language"] + + foreach_with_prefix lang $all_languages { + if { $lang == "auto" || $lang == "local" } { + # Avoid duplicate testing. + continue + } + + gdb_test_no_output "set language $lang" + + if {$lang == "unknown"} { + gdb_test "ptype \$_isvoid" \ + "expression parsing not implemented for language \"Unknown\"" + } elseif {$lang == "ada"} { + gdb_test "ptype \$_isvoid" "<>" + } else { + gdb_test "ptype \$_isvoid" "" + } + } +} + +clean_restart + +test_ptype_internal_function diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp index 0174b179e36..6066dae59da 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.exp +++ b/gdb/testsuite/gdb.python/py-xmethods.exp @@ -52,6 +52,9 @@ gdb_test "p a_geta" ".* = 1" "before: a_geta 1" gdb_test "p ++a1" "No symbol.*" "before: ++a1" gdb_test "p a1.getarrayind(5)" "Couldn't find method.*" \ "before: a1.getarrayind(5)" +gdb_test "ptype a1.getarrayind" \ + "There is no member or method named getarrayind\\." \ + "before: ptype a1.getarrayind" gdb_test "p a_ptr->geta()" ".* = 60" "before: a_ptr->geta()" gdb_test "p b_geta" ".* = 1" "before: b_geta 1" @@ -97,6 +100,10 @@ gdb_test "p a1.geta()" "From Python .*5" "after: a1.geta()" gdb_test "p ++a1" "From Python .*6" "after: ++a1" gdb_test "p a1.getarrayind(5)" "From Python .*5" \ "after: a1.getarrayind(5)" +gdb_test "ptype a1.getarrayind" \ + "There is no member or method named getarrayind\\." \ + "after: ptype a1.getarrayind" + gdb_test "p a1\[6\]" ".*int &.*6" "after a1\[\]" gdb_test "p b1\[7\]" ".*const int &.*7" "after b1\[\]" # Note the following test. Xmethods on dynamc types are not looked up