aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-02-23 13:50:18 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2020-06-09 04:09:00 -0400
commitc68d70e8bda9423f502351e88e464803f73941b4 (patch)
tree9599132d8355b589539eeef18904260dc710ddf8 /gcc
parentd68c6d7dcc46a50ec248f9989243f83ad9a3ca0e (diff)
downloadgcc-c68d70e8bda9423f502351e88e464803f73941b4.zip
gcc-c68d70e8bda9423f502351e88e464803f73941b4.tar.gz
gcc-c68d70e8bda9423f502351e88e464803f73941b4.tar.bz2
[Ada] Ada2020: AI12-0301 Predicates and Default_Value
2020-06-09 Arnaud Charlet <charlet@adacore.com> gcc/ada/ * sem_util.ads, sem_util.adb (Is_Partially_Initialized_Type): Take Default_Value and Default_Component_Value into account. * sem_ch3.adb (Analyze_Object_Declaration): Update comment.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/sem_ch3.adb6
-rw-r--r--gcc/ada/sem_util.adb7
-rw-r--r--gcc/ada/sem_util.ads3
3 files changed, 10 insertions, 6 deletions
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index c9dac2c..7882cb8 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -4366,8 +4366,10 @@ package body Sem_Ch3 is
-- We need a predicate check if the type has predicates that are not
-- ignored, and if either there is an initializing expression, or for
-- default initialization when we have at least one case of an explicit
- -- default initial value and then this is not an internal declaration
- -- whose initialization comes later (as for an aggregate expansion).
+ -- default initial value (including via a Default_Value or
+ -- Default_Component_Value aspect, see AI12-0301) and then this is not
+ -- an internal declaration whose initialization comes later (as for an
+ -- aggregate expansion).
-- If expression is an aggregate it may be expanded into assignments
-- and the declaration itself is marked with No_Initialization, but
-- the predicate still applies.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index f359fa2..a5a5815 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -16863,7 +16863,7 @@ package body Sem_Util is
is
begin
if Is_Scalar_Type (Typ) then
- return False;
+ return Has_Default_Aspect (Base_Type (Typ));
elsif Is_Access_Type (Typ) then
return Include_Implicit;
@@ -16872,8 +16872,9 @@ package body Sem_Util is
-- If component type is partially initialized, so is array type
- if Is_Partially_Initialized_Type
- (Component_Type (Typ), Include_Implicit)
+ if Has_Default_Aspect (Base_Type (Typ))
+ or else Is_Partially_Initialized_Type
+ (Component_Type (Typ), Include_Implicit)
then
return True;
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index ba4c289..2dfe34d 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -1872,7 +1872,8 @@ package Sem_Util is
-- Typ is a type entity. This function returns true if this type is partly
-- initialized, meaning that an object of the type is at least partly
-- initialized (in particular in the record case, that at least one
- -- component has an initialization expression). Note that initialization
+ -- component has an initialization expression, including via Default_Value
+ -- and Default_Component_Value aspects). Note that initialization
-- resulting from the use of pragma Normalize_Scalars does not count.
-- Include_Implicit controls whether implicit initialization of access
-- values to null, and of discriminant values, is counted as making the