[Ada] Spurious error reported by pragma Compile_Time_Error
The compiler may trigger spurious errors on pragmas Compile_Time_Error
and Compile_Time_Warning when their boolean expression computes the size
of a type. After this patch the following test compiles fine.
with Interfaces; use Interfaces;
package Types is
type Arr is array (1 .. 6) of Unsigned_8
with Size => 48,
Alignment => 1;
type Rec is record
Comp_1 : Unsigned_32;
Comp_2 : Unsigned_16;
end record
with Size => 48,
Alignment => 1;
end Types;
with Types; use Types;
package Main is
pragma Compile_Time_Error
(Arr'Size = 12, "ERROR: Arr'Size is 48, not 12");
pragma Compile_Time_Error
(Arr'Size = 48, "OK: Arr");
pragma Compile_Time_Error
(Arr'Size /= 48, "ERROR: Arr'Size is 48");
pragma Compile_Time_Error
(Rec'Size = 34, "ERROR: Rec'Size is 48, not 34");
pragma Compile_Time_Error
(Rec'Size = 48, "OK: Rec");
pragma Compile_Time_Error
(Rec'Size /= 48, "ERROR: Rec'Size is 48");
end Main;
Command: gcc -c main.ads
Output: main.ads:7:07: OK: Arr
main.ads:14:07: OK: Rec
2019-07-08 Javier Miranda <miranda@adacore.com>
gcc/ada/
* sem_attr.adb (Analyze_Attribute [Attribute_Size]): For pragmas
used to report user defined compile time warning or errors
handle 'Size for types with known static RM size.
From-SVN: r273200