DWARF array bounds missing from C++ array definitions
authorAlexandre Oliva <oliva@adacore.com>
Tue, 1 Oct 2019 11:36:31 +0000 (11:36 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 1 Oct 2019 11:36:31 +0000 (11:36 +0000)
commit31632e2c4327146ea8d21cff33adaa505b17d2bd
tree6a454c924b23547a07d090fa1686f7df8b8ad7fe
parentc7ea76ea5629e9f0357de49847274cf80e35f2f8
DWARF array bounds missing from C++ array definitions

A variable redeclaration or definition that provides additional type
information for it, e.g. outermost array bounds, is not reflected in
the debug information for the variable.  With this patch, the debug
info of the variable specialization gets a type attribute with the
adjusted type.

This patch affects mostly only array bounds.  However, when the
symbolic type used in a declaration and in a definition are different,
although they refer to the same type, debug information will end up
(correctly?) naming different symbolic types in the specification and
the definition.  Also, when a readonly declaration of an array loses
the readonly flag at the definition because of the initializer, the
definition may end up referencing a type while the specification
refers to a const-qualified version of that type.  If the type of the
variable is already const-qualified, e.g. an array of a const type,
the difference is meaningless.

for  gcc/ChangeLog

PR debug/91507
* dwarf2out.c (override_type_for_decl_p): New.
(gen_variable_die): Use it.

for  gcc/testsuite/ChangeLog

PR debug/91507
* gcc.dg/debug/dwarf2/array-0.c: New.
* gcc.dg/debug/dwarf2/array-1.c: New.
* gcc.dg/debug/dwarf2/array-2.c: New.
* gcc.dg/debug/dwarf2/array-3.c: New.
* g++.dg/debug/dwarf2/array-0.C: New.
* g++.dg/debug/dwarf2/array-1.C: New.
* g++.dg/debug/dwarf2/array-2.C: New.  Based on libstdc++-v3's
src/c++98/pool_allocator.cc:__pool_alloc_base::_S_heap_size.
* g++.dg/debug/dwarf2/array-3.C: New.  Based on
gcc's config/i386/i386-features.c:xlogue_layout::s_instances.
* g++.dg/debug/dwarf2/array-4.C: New.

From-SVN: r276403
12 files changed:
gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/debug/dwarf2/array-0.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/array-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/array-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/array-3.C [new file with mode: 0644]
gcc/testsuite/g++.dg/debug/dwarf2/array-4.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/array-0.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/array-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/array-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/debug/dwarf2/array-3.c [new file with mode: 0644]