[gdb/symtab] Fix handling of DW_TAG_unspecified_type
authorTom de Vries <tdevries@suse.de>
Sun, 11 Sep 2022 07:01:03 +0000 (09:01 +0200)
committerTom de Vries <tdevries@suse.de>
Sun, 11 Sep 2022 07:01:03 +0000 (09:01 +0200)
commita34a90995ae7c2f0c0b79ad32d8087d507fe42db
tree75bf74f90d3d068a2609d34fd662eaed0534742f
parent20a64ae9cb271e0ebcea2425e57b53f6d4a0c1d8
[gdb/symtab] Fix handling of DW_TAG_unspecified_type

Currently, the test-case contained in this patch fails:
...
(gdb) p (int) foo ()^M
Invalid cast.^M
(gdb) FAIL: gdb.dwarf2/dw2-unspecified-type.exp: p (int) foo ()
...
because DW_TAG_unspecified_type is translated as void.

There's some code in read_unspecified_type that marks the type as stub, but
that's only active for ada:
...
  if (cu->lang () == language_ada)
    type->set_is_stub (true);
...

Fix this by:
- marking the type as a stub for all languages, and
- handling the stub return type case in call_function_by_hand_dummy.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29558
gdb/dwarf2/read.c
gdb/infcall.c
gdb/testsuite/gdb.dwarf2/dw2-unspecified-type-foo.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dw2-unspecified-type.exp [new file with mode: 0644]