diff options
author | Ed Schonberg <schonberg@adacore.com> | 2018-12-11 11:11:17 +0000 |
---|---|---|
committer | Pierre-Marie de Rodat <pmderodat@gcc.gnu.org> | 2018-12-11 11:11:17 +0000 |
commit | 0a4578b6c6d1febbb569a473c1142135906cab18 (patch) | |
tree | 5f162034b1037aed62701a96d2c3c5dda2448783 /gcc/ada/gcc-interface/utils.c | |
parent | 0617753f4a5bda865efe66192841c40abdab8c2e (diff) | |
download | gcc-0a4578b6c6d1febbb569a473c1142135906cab18.zip gcc-0a4578b6c6d1febbb569a473c1142135906cab18.tar.gz gcc-0a4578b6c6d1febbb569a473c1142135906cab18.tar.bz2 |
[Ada] Missing predicate check on declaration with aggregate expression
This patch adds a missing predicate check on the initial value of an
object whose declaration initializes the object with an aggregate. Such
a declaration is marked No_Initialization to prevent a call to a default
initialization procedure, but the check is needed on the value of the
aggregate.
Executing the following:
gnatmake -q -gnata pred
./pred
must yield:
raised SYSTEM.ASSERTIONS.ASSERT_FAILURE :
Dynamic_Predicate failed at root.ads:30
----
with Root;
procedure Pred is
begin
null;
end Pred;
----
package Root with SPARK_Mode is
type Index_Type is range 1 .. Natural'Last;
type Element_Type is private;
Null_Element : constant Element_Type;
type Foobar_Type is array (Index_Type range <>) of Element_Type
with Dynamic_Predicate =>
Foobar_Type'First > 0 and Foobar_Type'Length > 0;
Null_Foobar : constant Foobar_Type;
private
type Kind_Type is (Kind_Invalid, Kind_Valid);
type Element_Type (Kind : Kind_Type := Kind_Invalid) is record
Index1 : Index_Type;
case Kind is
when Kind_Valid =>
Index2 : Index_Type;
when Kind_Invalid =>
null;
end case;
end record;
Null_Element : constant Element_Type := (Kind => Kind_Invalid,
Index1 => Index_Type'First);
Null_Foobar : constant Foobar_Type := (1 .. 0 => Null_Element);
end Root;
2018-12-11 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* sem_ch3.adb (Analyze_Object_Declaration): Apply
Dynamic_Predicate check to an object of an array type
initialized with an aggregate.
From-SVN: r267002
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
0 files changed, 0 insertions, 0 deletions