Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 213440) +++ sem_prag.adb (working copy) @@ -7838,8 +7838,14 @@ -- the code generator making an implicit initialization explicit. elsif Present (Expression (Parent (Def_Id))) - and then Comes_From_Source (Expression (Parent (Def_Id))) + and then Comes_From_Source + (Original_Node (Expression (Parent (Def_Id)))) then + + -- Set imported flag to prevent cascaded errors. + + Set_Is_Imported (Def_Id); + Error_Msg_Sloc := Sloc (Def_Id); Error_Pragma_Arg ("no initialization allowed for declaration of& #", @@ -7847,7 +7853,13 @@ Arg2); else - Set_Imported (Def_Id); + -- If the pragma comes from an aspect specification the + -- Is_Imported flag has already been set. + + if not From_Aspect_Specification (N) then + Set_Imported (Def_Id); + end if; + Process_Interface_Name (Def_Id, Arg3, Arg4); -- Note that we do not set Is_Public here. That's because we @@ -7922,8 +7934,13 @@ exit; else - Set_Imported (Def_Id); + -- If the pragma comes from an aspect specification the + -- Is_Imported flag has already been set. + if not From_Aspect_Specification (N) then + Set_Imported (Def_Id); + end if; + -- Reject an Import applied to an abstract subprogram if Is_Subprogram (Def_Id) Index: sem_ch13.adb =================================================================== --- sem_ch13.adb (revision 213446) +++ sem_ch13.adb (working copy) @@ -2915,6 +2915,21 @@ -- that verifed that there was a matching convention -- is now obsolete. + if A_Id = Aspect_Import then + Set_Is_Imported (E); + + -- An imported entity cannot have an explicit + -- initialization. + + if Nkind (N) = N_Object_Declaration + and then Present (Expression (N)) + then + Error_Msg_N + ("imported entities cannot be initialized " + & "(RM B.1(24))", Expression (N)); + end if; + end if; + goto Continue; end if; @@ -2930,7 +2945,7 @@ and then Nkind (Parent (N)) /= N_Compilation_Unit then Error_Msg_N - ("incorrect context for library unit aspect&", Id); + ("incorrect context for library unit aspect&", Id); goto Continue; end if;