]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Fix regression in ACATS bdd2006 and bdd2007
authorBob Duff <duff@adacore.com>
Thu, 8 Jul 2021 16:55:38 +0000 (12:55 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 21 Sep 2021 15:25:01 +0000 (15:25 +0000)
gcc/ada/

* sem_ch13.adb (Stream_Size): Print message about allowed stream
sizes even if other error were already found. This avoids
falling into the 'else', which prints "Stream_Size cannot be
given for...", which is misleading -- the Size COULD be given if
it were correct.

gcc/ada/sem_ch13.adb

index b6face3136d2a8dbc807acc7e7cdf4a47a0a8b12..228fd39998320d0190864020990984302c6fd33b 100644 (file)
@@ -7824,12 +7824,17 @@ package body Sem_Ch13 is
             if Duplicate_Clause then
                null;
 
-            elsif Is_Elementary_Type (U_Ent) and then Present (Size) then
-               if Size /= System_Storage_Unit
-                 and then Size /= System_Storage_Unit * 2
-                 and then Size /= System_Storage_Unit * 3
-                 and then Size /= System_Storage_Unit * 4
-                 and then Size /= System_Storage_Unit * 8
+            elsif Is_Elementary_Type (U_Ent) then
+               --  Size will be empty if we already detected an error
+               --  (e.g. Expr is of the wrong type); we might as well
+               --  give the useful hint below even in that case.
+
+               if No (Size) or else
+                 (Size /= System_Storage_Unit
+                  and then Size /= System_Storage_Unit * 2
+                  and then Size /= System_Storage_Unit * 3
+                  and then Size /= System_Storage_Unit * 4
+                  and then Size /= System_Storage_Unit * 8)
                then
                   Error_Msg_N
                     ("stream size for elementary type must be 8, 16, 24, " &