This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
RE: how to support C type qualifiers applied to arrays?
- From: Jim Wilson <wilson at specifix dot com>
- To: Gary Funck <gary at intrepid dot com>
- Cc: gdb at sourceware dot org, 'Daniel Jacobowitz' <drow at false dot org>
- Date: Mon, 01 Jan 2007 14:15:47 -0800
- Subject: RE: how to support C type qualifiers applied to arrays?
- References: <200612141837.kBEIb7Lw024917@intrepid.intrepid.com>
On Thu, 2006-12-14 at 12:22 -0800, Gary Funck wrote:
> The main difficulty is that GCC doesn't create new qualified
> types for declarations. Rather, it sets TREE_READONLY()
> and TREE_THIS_VOLATILE() in the DECL node for declarations
> such as:
> volatile int A[10];
If you look at the types created by the C front end, they are OK.
c_build_qualified_type knows how to handle an array correctly.
The problem arises in the DWARF2 output code. gen_type_die calls
type_main_variant for all types other than vector types, which strips
off the const and volatile type modifiers. Then it clumsily tries to
put them back later in gen_variable_die, except that for array types, it
puts them back in the wrong place.
This seems to answer the question I asked long ago. Why are we trying
to put back qualifiers from the decl? Because gen_type_die stripped
them off. This seems wrong.
If we fix gen_type_die to stop calling type_main_variant, and if we fix
gen_variable_die to stop adding back the type qualifiers, then I get the
right result. So I think I was on the right track before, we just need
another little change to gen_type_die in addition to what I already
described.
I haven't investigated this in detail yet. There may be other parts of
the code that expect to see a type main variant here, so we might need
other cascading fixes. This still seems fixable to me though.
--
Jim Wilson, GNU Tools Support, http://www.specifix.com