comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Detect arithmetic operator usage for user-defined integer type
Date: Thu, 16 Apr 2020 12:38:40 +0200
Date: 2020-04-16T12:38:40+02:00	[thread overview]
Message-ID: <r79cjf$i13$1@gioia.aioe.org> (raw)
In-Reply-To: 8afdbc7f-7089-437e-8be9-9abdb9a94a46@googlegroups.com

On 2020-04-16 12:07, gautier_niouzes@hotmail.com wrote:
> In a project I'm reworking, there is a type
> 
>    type Opcode is range 0 .. 79;
> 
> associated with values:
> 
>    k_Load_Address                  : constant := 0;
>    k_Push_Value                    : constant := 1;
>    ...
> 
> I'd like to define Opcode as an enumerated type:
> 
>    type Opcode is (k_Load_Address, k_Push_Value, ...);
> 
> The problem is that there are, in some places in the legacy code, arithmetic operations on Opcode values (ouch!). Is there a tool able to list those operations for the custom type Opcode, other than defining Opcode as enumerated and let the compiler find the arithmetic operations to be removed? Probably it's what I'll do ultimately, but maybe such a detection could be useful in another context.

You could define your own "+" on Opcode, recompile in GPS, and then 
"find all references" on "+". That should list it.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2020-04-16 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-16 10:07 Detect arithmetic operator usage for user-defined integer type gautier_niouzes
2020-04-16 10:38 ` Dmitry A. Kazakov [this message]
2020-04-16 18:42   ` gautier_niouzes
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox