diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2016-02-17 09:21:58 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2016-02-17 09:21:58 +0000 |
commit | e2f0522e06523c19b62d1acc9925a63401c82b63 (patch) | |
tree | 862c4536dcd6f54e1fa80604d57c816ab0b1ed03 | |
parent | bf17fe3f736580a65427cc9e0e814e3ffe6e7fe5 (diff) | |
download | gcc-e2f0522e06523c19b62d1acc9925a63401c82b63.zip gcc-e2f0522e06523c19b62d1acc9925a63401c82b63.tar.gz gcc-e2f0522e06523c19b62d1acc9925a63401c82b63.tar.bz2 |
exp_ch4.adb (Expand_N_Indexed_Component): Active synchronization if the prefix denotes an entity which Has_Atomic_Components.
* exp_ch4.adb (Expand_N_Indexed_Component): Active synchronization if
the prefix denotes an entity which Has_Atomic_Components.
* gcc-interface/trans.c (node_is_atomic): Return true if the prefix
denotes an entity which Has_Atomic_Components.
From-SVN: r233485
-rw-r--r-- | gcc/ada/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/ada/exp_ch4.adb | 5 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 3 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/atomic8.adb | 33 |
5 files changed, 51 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 60ff796..4868cae 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,12 @@ 2016-02-17 Eric Botcazou <ebotcazou@adacore.com> + * exp_ch4.adb (Expand_N_Indexed_Component): Active synchronization if + the prefix denotes an entity which Has_Atomic_Components. + * gcc-interface/trans.c (node_is_atomic): Return true if the prefix + denotes an entity which Has_Atomic_Components. + +2016-02-17 Eric Botcazou <ebotcazou@adacore.com> + * gcc-interface/utils2.c (gnat_protect_expr): Make a SAVE_EXPR only for fat pointer or scalar types. diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index 0b1fe79..eff75c2 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -6,7 +6,7 @@ -- -- -- B o d y -- -- -- --- Copyright (C) 1992-2015, Free Software Foundation, Inc. -- +-- Copyright (C) 1992-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- -- @@ -6269,6 +6269,9 @@ package body Exp_Ch4 is and then not Atomic_Synchronization_Disabled (Atp)) or else (Is_Atomic (Typ) and then not Atomic_Synchronization_Disabled (Typ)) + or else (Is_Entity_Name (P) + and then Has_Atomic_Components (Entity (P)) + and then not Atomic_Synchronization_Disabled (Entity (P))) then Activate_Atomic_Synchronization (N); end if; diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 0f626d4..fce3f0e 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -4028,6 +4028,9 @@ node_is_atomic (Node_Id gnat_node) case N_Indexed_Component: if (Has_Atomic_Components (Etype (Prefix (gnat_node)))) return true; + if (Is_Entity_Name (Prefix (gnat_node)) + && Has_Atomic_Components (Entity (Prefix (gnat_node)))) + return true; /* ... fall through ... */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 397b40f..59ce254 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2016-02-17 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/atomic8.adb: New test. + +2016-02-17 Eric Botcazou <ebotcazou@adacore.com> + * gnat.dg/discr46.ad[sb]: New test. 2016-02-16 Kelvin Nilsen <kelvin@gcc.gnu.org> diff --git a/gcc/testsuite/gnat.dg/atomic8.adb b/gcc/testsuite/gnat.dg/atomic8.adb new file mode 100644 index 0000000..76a110d --- /dev/null +++ b/gcc/testsuite/gnat.dg/atomic8.adb @@ -0,0 +1,33 @@ +-- { dg-do run } + +procedure Atomic8 is + + V : array (1 .. 2) of Natural := (0,0) with Atomic_Components; + + task type TT1; + task body TT1 is + begin + while V (1) + V (2) < 1_000_000 loop + V (1) := V (1) + 1; + end loop; + end TT1; + + task type TT2; + task body TT2 is + begin + while V (1) + V (2) < 1_000_000 loop + V (2) := V (2) + 1; + end loop; + end TT2; + +begin + declare + T1 : TT1; + T2 : TT2; + begin + null; + end; + if V (1) + V (2) not in 1_000_000 | 1_000_001 then + raise Program_Error; + end if; +end; |