* gcc-interface/trans.c (Subprogram_Body_to_gnu): Pop the stack of
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Sep 2013 10:21:37 +0000 (10:21 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Sep 2013 10:21:37 +0000 (10:21 +0000)
return variables for subprograms using the CICO mechanism.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@202684 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/in_out_parameter4.adb [new file with mode: 0644]

index c18f054..44edd72 100644 (file)
@@ -1,3 +1,8 @@
+2013-09-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (Subprogram_Body_to_gnu): Pop the stack of
+       return variables for subprograms using the CICO mechanism.
+
 2013-09-13  Dominique Dhumieres  <dominiq@lps.ens.fr>
 
        * gcc-interface/Makefile.in: Fix darwin Filter to match on $target_os,
index 4048e0a..923189a 100644 (file)
@@ -3605,6 +3605,8 @@ Subprogram_Body_to_gnu (Node_Id gnat_node)
     {
       tree gnu_retval;
 
+      gnu_return_var_stack->pop ();
+
       add_stmt (gnu_result);
       add_stmt (build1 (LABEL_EXPR, void_type_node,
                        gnu_return_label_stack->last ()));
index 2b1cad2..3fc1158 100644 (file)
@@ -1,3 +1,7 @@
+2013-09-18  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/in_out_parameter4.adb: New test.
+
 2013-09-18  Marek Polacek  <polacek@redhat.com>
 
        PR sanitizer/58411
diff --git a/gcc/testsuite/gnat.dg/in_out_parameter4.adb b/gcc/testsuite/gnat.dg/in_out_parameter4.adb
new file mode 100644 (file)
index 0000000..4f5cc21
--- /dev/null
@@ -0,0 +1,30 @@
+-- { dg-do run }
+-- { dg-options "-gnat12 -gnatVa" }
+
+procedure In_Out_Parameter4 is
+
+   type Enum is (E_Undetermined, E_Down, E_Up);
+   subtype Status_T is Enum range E_Down .. E_Up;
+
+   function Recurse (Val : in out Integer) return Status_T is
+
+     Result : Status_T;
+
+     procedure Dummy (I : in out Integer) is begin null; end;
+
+   begin
+     if Val > 500 then
+       Val := Val - 1;
+       Result := Recurse (Val);
+       return Result;
+     else
+       return E_UP;
+     end if;
+   end;
+
+   Val : Integer := 501;
+   S : Status_T;
+
+begin
+   S := Recurse (Val);
+end;