summaryrefslogtreecommitdiff
path: root/gcc/ada/sem_ch5.adb
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-05 07:54:48 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-05 07:54:48 +0000
commit166ee026cdc41c3bf1b5a1379ddce8c6253b8d3b (patch)
treed7a5a8f5007bee419ecccaf73a6db9e7c78b677e /gcc/ada/sem_ch5.adb
parent8a2fc7f3949873ca97069d89a39e48a8982b6b68 (diff)
downloadgcc-166ee026cdc41c3bf1b5a1379ddce8c6253b8d3b.tar.gz
2005-09-01 Javier Miranda <miranda@adacore.com>
* itypes.ads, itypes.adb (Create_Null_Excluding_Itype): New subprogram that given an entity T creates and returns an Itype that duplicates the contents of T. The returned Itype has the null-exclusion attribute set to True, and its Etype attribute references T to keep the association between the two entities. Update copyright notice * sem_aggr.adb (Check_Can_Never_Be_Null, Aggregate_Constraint_Checks, Resolve_Aggregate, Resolve_Array_Aggregate, Resolve_Record_Aggregate): Code cleanup. * sem_ch5.adb (Analyze_Assignment): Code cleanup. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103868 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/sem_ch5.adb')
-rw-r--r--gcc/ada/sem_ch5.adb30
1 files changed, 16 insertions, 14 deletions
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index b07389a8f36..2c5e0642bf0 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -375,9 +375,7 @@ package body Sem_Ch5 is
T2 := Etype (Rhs);
- if Covers (T1, T2) then
- null;
- else
+ if not Covers (T1, T2) then
Wrong_Type (Rhs, Etype (Lhs));
return;
end if;
@@ -448,17 +446,21 @@ package body Sem_Ch5 is
-- Ada 2005 (AI-231)
if Ada_Version >= Ada_05
- and then Nkind (Rhs) = N_Null
- and then Is_Access_Type (T1)
+ and then Can_Never_Be_Null (T1)
and then not Assignment_OK (Lhs)
- and then ((Is_Entity_Name (Lhs)
- and then Can_Never_Be_Null (Entity (Lhs)))
- or else Can_Never_Be_Null (Etype (Lhs)))
then
- Apply_Compile_Time_Constraint_Error
- (N => Lhs,
- Msg => "(Ada 2005) NULL not allowed in null-excluding objects?",
- Reason => CE_Null_Not_Allowed);
+ if Nkind (Rhs) = N_Null then
+ Apply_Compile_Time_Constraint_Error
+ (N => Rhs,
+ Msg => "(Ada 2005) NULL not allowed in null-excluding objects?",
+ Reason => CE_Null_Not_Allowed);
+ return;
+
+ elsif not Can_Never_Be_Null (T2) then
+ Rewrite (Rhs,
+ Convert_To (T1, Relocate_Node (Rhs)));
+ Analyze_And_Resolve (Rhs, T1);
+ end if;
end if;
if Is_Scalar_Type (T1) then
@@ -550,7 +552,7 @@ package body Sem_Ch5 is
Ent := Entity (Lhs);
- -- Capture value if save to do so
+ -- Capture value if safe to do so
if Safe_To_Capture_Value (N, Ent) then
Set_Current_Value (Ent, Rhs);
@@ -1274,7 +1276,7 @@ package body Sem_Ch5 is
-- Start of processing for Process_Bounds
begin
- -- Determine expected type of range by analyzing separate copy.
+ -- Determine expected type of range by analyzing separate copy
Set_Parent (R_Copy, Parent (R));
Pre_Analyze_And_Resolve (R_Copy);