From 75ad5042832e9f76566a3f841f9c7701ccd071ee Mon Sep 17 00:00:00 2001 From: Ed Schonberg Date: Mon, 4 Aug 2008 12:22:48 +0200 Subject: [PATCH] sem_ch4.adb (Analyze_Allocator): If the designated type is a non-null access type and the allocator is not... 2008-08-04 Ed Schonberg * sem_ch4.adb (Analyze_Allocator): If the designated type is a non-null access type and the allocator is not initialized, warn rather than reporting an error. From-SVN: r138600 --- gcc/ada/sem_ch4.adb | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb index 5f23ca2..2129a27 100644 --- a/gcc/ada/sem_ch4.adb +++ b/gcc/ada/sem_ch4.adb @@ -498,11 +498,24 @@ package body Sem_Ch4 is Set_Directly_Designated_Type (Acc_Type, Type_Id); Check_Fully_Declared (Type_Id, N); - -- Ada 2005 (AI-231) + -- Ada 2005 (AI-231) If the designated type is itself an access + -- type that excludes null, it's default initializastion will + -- be a null object, and we can insert an unconditional raise + -- before the allocator. if Can_Never_Be_Null (Type_Id) then - Error_Msg_N ("(Ada 2005) qualified expression required", - Expression (N)); + declare + Not_Null_Check : constant Node_Id := + Make_Raise_Constraint_Error (Sloc (E), + Reason => CE_Null_Not_Allowed); + begin + if Expander_Active then + Insert_Action (N, Not_Null_Check); + Analyze (Not_Null_Check); + else + Error_Msg_N ("null value not allowed here?", E); + end if; + end; end if; -- Check restriction against dynamically allocated protected -- 2.7.4