This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Ada] Infinite loop while analysing aspect Global


This patch corrects the check of a Global item of mode In_Out or Out that
appear as an input in the Global aspect of an enclosing subprogram. Prior to
this patch, the check caused an infinite loop in certain scenarios.

------------
-- Source --
------------

--  stack_overflow.adb

procedure Stack_Overflow is
   X : Integer;

   procedure Error
      with Global => (Input => X)
   is
      procedure OK_1
         with Global => (In_Out => X)
      is
         procedure OK_2 (Par1 : out Integer)
            with Global => (In_Out => X)
         is
         begin
            X := X + 1;
            Par1 := X;
         end OK_2;
      begin
         null;
      end OK_1;
   begin
      null;
   end Error;
begin
   null;
end Stack_Overflow;

-----------------
-- Compilation --
-----------------

$ gcc -c -gnat12 -gnatd.V stack_overflow.adb
stack_overflow.adb:8:36: global item "X" cannot have mode In_Out or Output
stack_overflow.adb:8:36: item already appears as input of subprogram "Error"

Tested on x86_64-pc-linux-gnu, committed on trunk

2013-09-10  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_prag.adb (Check_Mode_Restriction_In_Enclosing_Context): Add local
	variable Context.  Remove local variable Subp_Id. Start the
	context traversal from the current subprogram rather than the
	current scope. Update the scope traversal and error reporting.

Attachment: difs
Description: Text document


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