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

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