Contract nodes are meant to carry information for subprogram spec entities, not subprogram body entities (for bodies that are completions of specs). So we remove the contract node when a spec entity is changed to a body entity. Depending on how refined contracts on bodies are handled, this may need to be updated in the future.
Tested on x86_64-pc-linux-gnu, committed on trunk 2013-04-24 Yannick Moy <m...@adacore.com> * sem_ch6.adb (Analyze_Generic_Subprogram_Body, Analyze_Subprogram_Body_Helper): Reset contract node to Empty before setting entity to E_Subprogram_Body. * sem_ch8.adb (Analyze_Subprogram_Renaming): Reset contract node to Empty before setting entity to E_Subprogram_Body.
Index: sem_ch6.adb =================================================================== --- sem_ch6.adb (revision 198237) +++ sem_ch6.adb (working copy) @@ -1107,6 +1107,7 @@ -- Visible generic entity is callable within its own body Set_Ekind (Gen_Id, Ekind (Body_Id)); + Set_Contract (Body_Id, Empty); Set_Ekind (Body_Id, E_Subprogram_Body); Set_Convention (Body_Id, Convention (Gen_Id)); Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Gen_Id)); @@ -2902,6 +2903,7 @@ end if; Set_Corresponding_Body (Unit_Declaration_Node (Spec_Id), Body_Id); + Set_Contract (Body_Id, Empty); Set_Ekind (Body_Id, E_Subprogram_Body); Set_Scope (Body_Id, Scope (Spec_Id)); Set_Is_Obsolescent (Body_Id, Is_Obsolescent (Spec_Id)); Index: sem_ch8.adb =================================================================== --- sem_ch8.adb (revision 198221) +++ sem_ch8.adb (working copy) @@ -2435,6 +2435,7 @@ -- constructed later at the freeze point, so indicate that the -- completion has not been seen yet. + Set_Contract (New_S, Empty); Set_Ekind (New_S, E_Subprogram_Body); New_S := Rename_Spec; Set_Has_Completion (Rename_Spec, False);