[Ada] Add warning for overlays changing scalar storage order
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 30 May 2020 09:14:12 +0000 (11:14 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 10 Jul 2020 09:16:23 +0000 (05:16 -0400)
gcc/ada/

* sem_ch13.adb (Analyze_Attribute_Definition_Clause) <Address>:
Issue an unconditional warning for an overlay that changes the
scalar storage order.

gcc/ada/sem_ch13.adb

index bad6a96fe5ab9820de25262973069e4ccaee729c..4bdd2cf8bd3b2f1acf3ddb36e35136d85b23a314 100644 (file)
@@ -6075,10 +6075,10 @@ package body Sem_Ch13 is
                           (N, U_Ent, No_Uint, O_Ent, Off);
                      end if;
 
-                     --  If the overlay changes the storage order, mark the
-                     --  entity as being volatile to block any optimization
-                     --  for it since the construct is not really supported
-                     --  by the back end.
+                     --  If the overlay changes the storage order, warn since
+                     --  the construct is not really supported by the back end.
+                     --  Also mark the entity as being volatile to block the
+                     --  optimizer, even if there is no warranty on the result.
 
                      if (Is_Record_Type (Etype (U_Ent))
                           or else Is_Array_Type (Etype (U_Ent)))
@@ -6087,6 +6087,8 @@ package body Sem_Ch13 is
                        and then Reverse_Storage_Order (Etype (U_Ent)) /=
                                 Reverse_Storage_Order (Etype (O_Ent))
                      then
+                        Error_Msg_N
+                          ("??overlay changes scalar storage order", Expr);
                         Set_Treat_As_Volatile (U_Ent);
                      end if;