This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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, GAS/ARM] Clarify relation between reg_expected_msgs and arm_reg_type


Hi Thomas,

> Uses of reg_expected_msgs rely on each arm_reg_type enumerator to have a
> message entry in the same order as the enumerator declaration. This is
> not clearly stated in the definition of both the arm_reg_type enum and
> the reg_expected_msgs. Worse, there is nothing to ensure both are kept
> in sync.

There is a similar problem in other parts of the binutils sources too.
The usual way to solve it is to arrange for a compile time error if the
enum and the array are different sizes.  For example, in bfd/dwarf2.c
there is:

  extern int dwarf_debug_section_assert[ARRAY_SIZE (dwarf_debug_sections)
				      == debug_max + 1 ? 1 : -1];


> As an attempt towards this, this patch uses C99 array designators to
> ensure that each message is associated with the right arm_reg_type.

[I was going to add a whole paragraph here about how we need the sources
to remain compilable on older machines with older compilers that do not 
have C99 support.  But then it occurred to me that C99 is almost 20 years
old now and we really should be able to use its features.  So ...]

Sure - this makes sense.


> A comment is also added near the definition of arm_reg_type to point to
> the reg_expected_msgs array. 

Comments are good.  I like comments.


> Finally, the array is synced with
> arm_reg_type by adding the missing error message for REG_TYPE_RNB.

No problems with that.


> 2017-11-14  Thomas Preud'homme  <thomas.preudhomme@arm.com>
>
>    * config/tc-arm.c (arm_reg_type): Comment on the link with
>    reg_expected_msgs.
>    (reg_expected_msgs): Initialize using array designators with
>    arm_reg_type index.

Approved - please apply.

Cheers
  Nick


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