+gdb_test "ptype nested_su.inner_union_instance" "type = union ${outer}inner_union \{.*\[\r\n\] int inner_union_int;.*\[\r\n\] (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
+
+
+get_debug_format
+
+# Print the type of the identifier ID, and check the response:
+# - Expect to see PROTOTYPED as the type. PROTOTYPED is not a regular
+# expression; it's a literal string.
+# - If we instead see the unprototyped type PLAIN, and we're using STABS
+# generated by GCC, that's an xfail; as of 9 Feb 2002, GCC never emits
+# prototyped function types in STABS. Like PROTOTYPED, PLAIN is a
+# literal string, not a regular expression.
+# - Otherwise, it's a failure.
+proc ptype_maybe_prototyped { id prototyped plain } {
+ global gdb_prompt
+ global gcc_compiled
+
+ # Turn `prototyped' and `plain', which are literal strings, into
+ # regular expressions by quoting any special characters they contain.
+ regsub -all "\[\]\[*()\]" $prototyped "\\\\&" prototyped
+ regsub -all "\[\]\[*()\]" $plain "\\\\&" plain
+
+ send_gdb "ptype $id\n"
+ gdb_expect {
+ -re "type = $prototyped\[\r\n\]+$gdb_prompt $" {
+ pass "ptype $id"
+ }
+ -re "type = $plain\[\r\n\]+$gdb_prompt $" {
+ if {$gcc_compiled} { setup_xfail_format "stabs" }
+ fail "ptype $id (compiler doesn't emit prototyped types)"
+ }
+ -re "$gdb_prompt $" {
+ fail "ptype $id"
+ }
+ timeout {
+ fail "ptype $id (timeout)"
+ }
+ }
+}
+
+ptype_maybe_prototyped "func_type" "int (*)(int (*)(int, float), float)" \
+ "int (*)()"
+ptype_maybe_prototyped "old_fptr" "double (*)()" "double (*)()"
+ptype_maybe_prototyped "new_fptr" "double (*)(void)" "double (*)()"
+ptype_maybe_prototyped "fptr" "int (*)(int, float)" "int (*)()"
+ptype_maybe_prototyped "fptr2" "int *(*)(int (*)(int, float), float)" \
+ "int *(*)()"
+ptype_maybe_prototyped "xptr" "int (*)(int (*)(), int (*)(void), int)" \
+ "int (*)()"
+ptype_maybe_prototyped "ffptr" "int (*(*)(char))(short int)" \
+ "int (*(*)())()"
+ptype_maybe_prototyped "fffptr" "int (*(*(*)(char))(short int))(long int)" \
+ "int (*(*(*)())())()"
+
+# Test printing type of typedefs in different scopes, with same name
+# but different type.
+
+gdb_test "list intfoo" ""
+gdb_test "ptype foo" "type = int" "ptype foo typedef after first list of intfoo"
+gdb_test "list charfoo" ""
+gdb_test "ptype foo" "type = char" "ptype foo typedef after first list of charfoo"
+gdb_test "list intfoo" ""
+gdb_test "ptype foo" "type = int" "ptype foo typedef after second list of intfoo"
+gdb_test "list charfoo" ""
+gdb_test "ptype foo" "type = char" "ptype foo typedef after second list of charfoo"