comp.lang.ada
 help / color / mirror / Atom feed
* Syntax of extended return statement
@ 2011-03-16  0:01 Bill Findlay
  2011-03-16  2:23 ` Robert A Duff
  2011-03-16 10:28 ` Julian Leyh
  0 siblings, 2 replies; 4+ messages in thread
From: Bill Findlay @ 2011-03-16  0:01 UTC (permalink / raw)


I have the following compilation warning from GNAT:

   function pop
   return KDF9.word is
   begin
      the_nest_depth := the_nest_depth - 1;
      return result : KDF9.word := the_nest(the_nest_depth) do
             |
>>> warning: "result" is not modified, could be declared constant
         the_nest(the_nest_depth) := 0;
      end return;
   end pop;

If I change the return statement to:

      return result : constant KDF9.word := the_nest(the_nest_depth) do
         the_nest(the_nest_depth) := 0;
      end return;

it compiles without warning.

My problem is that I see no justification for that in the Ada 2005 RM, which
gives:

extended_return_statement ::=

return defining_identifier:[aliased] return_subtype_indication[:=expression]
[do
   handled_sequence_of_statements
end return]; 

return_subtype_indication ::= subtype_indication | access_definition

Can anyone enlighten me?

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Syntax of extended return statement
  2011-03-16  0:01 Syntax of extended return statement Bill Findlay
@ 2011-03-16  2:23 ` Robert A Duff
  2011-03-16 17:03   ` Bill Findlay
  2011-03-16 10:28 ` Julian Leyh
  1 sibling, 1 reply; 4+ messages in thread
From: Robert A Duff @ 2011-03-16  2:23 UTC (permalink / raw)


Bill Findlay <news@findlayw.plus.com> writes:

> My problem is that I see no justification for that in the Ada 2005 RM, which
> gives:
>
> extended_return_statement ::=
>
> return defining_identifier:[aliased] return_subtype_indication[:=expression]
> [do
>    handled_sequence_of_statements
> end return]; 
...
> Can anyone enlighten me?

"constant" is allowed by AI05-0015.  If you look at the latest version
of the RM, you will see that syntax allowed.

- Bob



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Syntax of extended return statement
  2011-03-16  0:01 Syntax of extended return statement Bill Findlay
  2011-03-16  2:23 ` Robert A Duff
@ 2011-03-16 10:28 ` Julian Leyh
  1 sibling, 0 replies; 4+ messages in thread
From: Julian Leyh @ 2011-03-16 10:28 UTC (permalink / raw)


On 16 Mrz., 01:01, Bill Findlay <n...@findlayw.plus.com> wrote:
> I have the following compilation warning from GNAT:
>
>    function pop
>    return KDF9.word is
>    begin
>       the_nest_depth := the_nest_depth - 1;
>       return result : KDF9.word := the_nest(the_nest_depth) do
>              |>>> warning: "result" is not modified, could be declared constant
>
>          the_nest(the_nest_depth) := 0;
>       end return;
>    end pop;

"result" is not modified, so the warning is correct.



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Syntax of extended return statement
  2011-03-16  2:23 ` Robert A Duff
@ 2011-03-16 17:03   ` Bill Findlay
  0 siblings, 0 replies; 4+ messages in thread
From: Bill Findlay @ 2011-03-16 17:03 UTC (permalink / raw)


On 16/03/2011 02:23, in article wccoc5bkdmd.fsf@shell01.TheWorld.com,
"Robert A Duff" <bobduff@shell01.TheWorld.com> wrote:

> Bill Findlay <news@findlayw.plus.com> writes:
> 
>> My problem is that I see no justification for that in the Ada 2005 RM, which
>> gives:
>> 
>> extended_return_statement ::=
>> 
>> return defining_identifier:[aliased] return_subtype_indication[:=expression]
>> [do
>>    handled_sequence_of_statements
>> end return]; 
> ...
> 
>> Can anyone enlighten me?
> 
> "constant" is allowed by AI05-0015.  If you look at the latest version
> of the RM, you will see that syntax allowed.

Aha! Out-of-date RM! Now I can sleep easy. 8-)

Thanks, Bob.

-- 
Bill Findlay
with blueyonder.co.uk;
use  surname & forename;




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-16 17:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-16  0:01 Syntax of extended return statement Bill Findlay
2011-03-16  2:23 ` Robert A Duff
2011-03-16 17:03   ` Bill Findlay
2011-03-16 10:28 ` Julian Leyh

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