From 9deff0440802c41fcd72b87c06d9e1fb3e00a773 Mon Sep 17 00:00:00 2001 From: charlet Date: Mon, 30 Jan 2012 12:16:12 +0000 Subject: 2012-01-30 Robert Dewar * sem.adb (Analyze): Call Analyze_Mod for N_Op_Mod mode. * sem_ch3.adb (Modular_Type_Declaration): Warn on mod value of form 2 * small-literal. * sem_ch4.adb (Analyze_Mod): New procedure (warn on suspicious mod value). * sem_ch4.ads (Analyze_Mod): New procedure. 2012-01-30 Ed Schonberg * sem_ch6.adb: sem_ch6.adb (Analyze_Expression_Function): Copy types and return expression when building spec for implicit body, to preserve global references that may be present in an instantiation. 2012-01-30 Matthew Heaney * a-convec.adb, a-coinve.adb, a-cobove.adb (Sort, Reverse_Elements): Check for cursor tampering. 2012-01-30 Ed Schonberg * sem_util.adb (Is_Fully_Initialized_Type): In Ada 2012, a type with aspect Default_Value or Default_Component_Value is fully initialized, and use of variables of such types do not generate warnings. 2012-01-30 Vincent Celier * projects.texi: Add documentation for attribute Interfaces. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183714 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ada/a-cobove.adb | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'gcc/ada/a-cobove.adb') diff --git a/gcc/ada/a-cobove.adb b/gcc/ada/a-cobove.adb index 99659abc795..aaf69c31213 100644 --- a/gcc/ada/a-cobove.adb +++ b/gcc/ada/a-cobove.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 2004-2011, Free Software Foundation, Inc. -- +-- Copyright (C) 2004-2012, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- @@ -931,8 +931,7 @@ package body Ada.Containers.Bounded_Vectors is -- Sort -- ---------- - procedure Sort (Container : in out Vector) - is + procedure Sort (Container : in out Vector) is procedure Sort is new Generic_Array_Sort (Index_Type => Count_Type, @@ -940,14 +939,27 @@ package body Ada.Containers.Bounded_Vectors is Array_Type => Elements_Array, "<" => "<"); + -- Start of processing for Sort + begin if Container.Last <= Index_Type'First then return; end if; - if Container.Lock > 0 then + -- The exception behavior for the vector container must match that + -- for the list container, so we check for cursor tampering here + -- (which will catch more things) instead of for element tampering + -- (which will catch fewer things). It's true that the elements of + -- this vector container could be safely moved around while (say) an + -- iteration is taking place (iteration only increments the busy + -- counter), and so technically all we would need here is a test for + -- element tampering (indicated by the lock counter), that's simply + -- an artifact of our array-based implementation. Logically Sort + -- requires a check for cursor tampering. + + if Container.Busy > 0 then raise Program_Error with - "attempt to tamper with elements (vector is locked)"; + "attempt to tamper with cursors (vector is busy)"; end if; Sort (Container.Elements (1 .. Container.Length)); @@ -2234,9 +2246,20 @@ package body Ada.Containers.Bounded_Vectors is return; end if; - if Container.Lock > 0 then + -- The exception behavior for the vector container must match that for + -- the list container, so we check for cursor tampering here (which will + -- catch more things) instead of for element tampering (which will catch + -- fewer things). It's true that the elements of this vector container + -- could be safely moved around while (say) an iteration is taking place + -- (iteration only increments the busy counter), and so technically all + -- we would need here is a test for element tampering (indicated by the + -- lock counter), that's simply an artifact of our array-based + -- implementation. Logically Reverse_Elements requires a check for + -- cursor tampering. + + if Container.Busy > 0 then raise Program_Error with - "attempt to tamper with elements (vector is locked)"; + "attempt to tamper with cursors (vector is busy)"; end if; Idx := 1; -- cgit v1.2.1