This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Handle volatile array types in dwarf2read.c.


>>>>> "Mark" == Mark Wielaard <mjw@redhat.com> writes:

Mark> read_tag_const_type propagates the cv-qualifier to the array
Mark> element type, but read_tag_volatile_type didn't. Make sure that
Mark> both cv-qualifiers that apply to array types are handled the same.

Thanks Mark.

Mark> 	* gdb.base/constvars.c (violent, violet, vips, virgen, vulgar,
Mark> 	vulture, vilify, villar): New volatile array constants.
Mark> 	(vindictive, vegetation): New const volatile array constants.

Lovely names.

Mark> +   the cv-qualifiers.  This is mimics section 6.7.3 of the C99
Mark> +   specification.  */

"This is" -> "This".

Mark> +static struct type *
Mark> +add_array_cv_type (struct die_info *die, struct dwarf2_cu *cu,
Mark> +		   struct type *base_type, int cnst, int voltl)

gdb usually puts a blank line between the intro comment and the function
head.

Mark> +  while (TYPE_CODE (TYPE_TARGET_TYPE (inner_array)) == TYPE_CODE_ARRAY)
Mark> +    {
Mark> +      TYPE_TARGET_TYPE (inner_array) =
Mark> +	copy_type (TYPE_TARGET_TYPE (inner_array));
Mark> +      inner_array = TYPE_TARGET_TYPE (inner_array);
Mark> +    }

I think this may be overly eager in the case where the underlying type
already has the needed qualifications.

Mark> +  cnst |= TYPE_CONST (el_type);
Mark> +  voltl |= TYPE_VOLATILE (el_type);
Mark> +  TYPE_TARGET_TYPE (inner_array) = make_cv_type (cnst, voltl, el_type, NULL);

make_cv_type preserves the already existing qualifiers so you don't need
to track "cnst" and "voltl".  You can just pass in the ones you want to
add.

Mark> +  /* In case the volatile qualifier is applied to an array type, the
Mark> +     element type is so qualified, not the array type (section 6.7.3
Mark> +     of C99).  */
Mark> +  if (TYPE_CODE (base_type) == TYPE_CODE_ARRAY)
Mark> +    return add_array_cv_type (die, cu, base_type, 0, 1);

I wonder about typedefs to array type.
Calling check_typedef here is probably not so great but I assume we can
just ignore incomplete types.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]