summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-21 10:21:56 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2016-04-21 10:21:56 +0000
commitee91a8d2e0f3a4ffbff991d0d1e7b9d3893ed53b (patch)
tree2531510ab31abff31d085218ba5a2eb6e9076c65
parent39adf1e61af850c8ebd1a103535a650ceba9924a (diff)
downloadgcc-ee91a8d2e0f3a4ffbff991d0d1e7b9d3893ed53b.tar.gz
2016-04-21 Arnaud Charlet <charlet@adacore.com>
* a-tasatt.adb, a-tasatt.ads (Fast_Path): Rewritten to avoid reading potentially uninitialized memory. * sem_ch3.adb: Minor style fix in comment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235329 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/a-tasatt.adb14
-rw-r--r--gcc/ada/a-tasatt.ads7
-rw-r--r--gcc/ada/sem_ch3.adb4
4 files changed, 23 insertions, 8 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 3e89814ed82..3dcc02d1672 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2016-04-21 Arnaud Charlet <charlet@adacore.com>
+ * a-tasatt.adb, a-tasatt.ads (Fast_Path): Rewritten to avoid reading
+ potentially uninitialized memory.
+ * sem_ch3.adb: Minor style fix in comment.
+
+2016-04-21 Arnaud Charlet <charlet@adacore.com>
+
* gnat_rm.texi, gnat_ugn.texi,
doc/gnat_ugn/gnat_project_manager.rst,
doc/gnat_ugn/building_executable_programs_with_gnat.rst,
diff --git a/gcc/ada/a-tasatt.adb b/gcc/ada/a-tasatt.adb
index e0ef9b22fb5..1eb7d592712 100644
--- a/gcc/ada/a-tasatt.adb
+++ b/gcc/ada/a-tasatt.adb
@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
--- Copyright (C) 2014, Free Software Foundation, Inc. --
+-- Copyright (C) 2014-2016, 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- --
@@ -93,6 +93,11 @@ package body Ada.Task_Attributes is
function To_Attribute is new
Ada.Unchecked_Conversion (Atomic_Address, Attribute);
+ function To_Address is new
+ Ada.Unchecked_Conversion (Attribute, System.Address);
+ function To_Int is new
+ Ada.Unchecked_Conversion (Attribute, Integer);
+
pragma Warnings (On);
function To_Address is new
@@ -114,9 +119,12 @@ package body Ada.Task_Attributes is
Ada.Unchecked_Deallocation (Real_Attribute, Real_Attribute_Access);
Fast_Path : constant Boolean :=
- Attribute'Size <= Atomic_Address'Size
+ (Attribute'Size = Integer'Size
+ and then Attribute'Alignment <= Atomic_Address'Alignment
+ and then To_Int (Initial_Value) = 0)
+ or else (Attribute'Size = System.Address'Size
and then Attribute'Alignment <= Atomic_Address'Alignment
- and then To_Address (Initial_Value) = 0;
+ and then To_Address (Initial_Value) = System.Null_Address);
-- If the attribute fits in an Atomic_Address (both size and alignment)
-- and Initial_Value is 0 (or null), then we will map the attribute
-- directly into ATCB.Attributes (Index), otherwise we will create
diff --git a/gcc/ada/a-tasatt.ads b/gcc/ada/a-tasatt.ads
index a3e1f0eddc3..857cdd7956b 100644
--- a/gcc/ada/a-tasatt.ads
+++ b/gcc/ada/a-tasatt.ads
@@ -6,7 +6,7 @@
-- --
-- S p e c --
-- --
--- Copyright (C) 2014, Free Software Foundation, Inc. --
+-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
@@ -42,8 +42,9 @@ generic
package Ada.Task_Attributes is
-- Note that this package will use an efficient implementation with no
- -- locks and no extra dynamic memory allocation if Attribute can fit in a
- -- System.Address type, and Initial_Value is 0 (null for an access type).
+ -- locks and no extra dynamic memory allocation if Attribute is the size
+ -- of either Integer or System.Address, and Initial_Value is 0 (null for
+ -- an access type).
-- Other types and initial values are supported, but will require
-- the use of locking and a level of indirection (meaning extra dynamic
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index cd5fd8f8e9f..0560a69f564 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -3423,7 +3423,7 @@ package body Sem_Ch3 is
if Error_Posted (N) then
- -- Type mismatch or illegal redeclaration, Do not analyze
+ -- Type mismatch or illegal redeclaration; do not analyze
-- expression to avoid cascaded errors.
T := Find_Type_Of_Object (Object_Definition (N), N);
@@ -3460,7 +3460,7 @@ package body Sem_Ch3 is
end if;
-- Ada 2005 (AI-231): Propagate the null-excluding attribute and carry
- -- out some static checks
+ -- out some static checks.
if Ada_Version >= Ada_2005 and then Can_Never_Be_Null (T) then