public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Fix slices and qualified expressions being effectively volatile
@ 2020-07-15 13:45 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2020-07-15 13:45 UTC (permalink / raw)
  To: gcc-patches; +Cc: Piotr Trojanek

[-- Attachment #1: Type: text/plain, Size: 941 bytes --]

Detecting effectively volatile objects in restricted contexts happens in
two routines: Is_Effectively_Volatile_Object and Is_OK_Volatile_Context.
Their handling of type conversions and slices were different; also none
of them has been dealing with qualified expressions, which has been just
added to list of non-interfering contexts in SPARK RM 7.1.3(10).

The change only affects SPARK code, as both "effectively volatile" and
"non-interfering context" are specific to SPARK.

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

gcc/ada/

	* exp_ch5.adb (Expand_Assign_Array): Use short-circuit operator
	(style).
	* sem_res.adb (Resolve_Indexed_Component): Fix style in comment.
	* sem_util.adb (Is_Effectively_Volatile_Object): Handle slices
	just like indexed components; handle qualified expressions and
	type conversions lie in Is_OK_Volatile_Context.
	(Is_OK_Volatile_Context): Handle qualified expressions just like
	type conversions.

[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 2265 bytes --]

diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb
--- a/gcc/ada/exp_ch5.adb
+++ b/gcc/ada/exp_ch5.adb
@@ -1521,7 +1521,7 @@ package body Exp_Ch5 is
       --  be assigned.
 
       elsif Possible_Bit_Aligned_Component (Lhs)
-              or
+              or else
             Possible_Bit_Aligned_Component (Rhs)
       then
          null;


diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -9155,7 +9155,7 @@ package body Sem_Res is
          Array_Type := Implicitly_Designated_Type (Array_Type);
       end if;
 
-      --  If name was overloaded, set component type correctly now
+      --  If name was overloaded, set component type correctly now.
       --  If a misplaced call to an entry family (which has no index types)
       --  return. Error will be diagnosed from calling context.
 


diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -15676,7 +15676,7 @@ package body Sem_Util is
          return Is_Object (Entity (N))
            and then Is_Effectively_Volatile (Entity (N));
 
-      elsif Nkind (N) = N_Indexed_Component then
+      elsif Nkind_In (N, N_Indexed_Component, N_Slice) then
          return Is_Effectively_Volatile_Object (Prefix (N));
 
       elsif Nkind (N) = N_Selected_Component then
@@ -15685,6 +15685,12 @@ package body Sem_Util is
              or else
            Is_Effectively_Volatile_Object (Selector_Name (N));
 
+      elsif Nkind_In (N, N_Qualified_Expression,
+                         N_Unchecked_Type_Conversion,
+                         N_Type_Conversion)
+      then
+         return Is_Effectively_Volatile_Object (Expression (N));
+
       else
          return False;
       end if;
@@ -17497,7 +17503,8 @@ package body Sem_Util is
       --  The volatile object appears as the expression of a type conversion
       --  occurring in a non-interfering context.
 
-      elsif Nkind_In (Context, N_Type_Conversion,
+      elsif Nkind_In (Context, N_Qualified_Expression,
+                               N_Type_Conversion,
                                N_Unchecked_Type_Conversion)
         and then Expression (Context) = Obj_Ref
         and then Is_OK_Volatile_Context



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-15 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-15 13:45 [Ada] Fix slices and qualified expressions being effectively volatile Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).