This fixes a problem in the diagnostic for violation of the restriction No_Elaboration_Code_All. In some cases, the location of the restriction incorrectly points to the pragma in system.ads. The following test should compile as shown whether or not there is a NECA pragma in System.
1. pragma Restrictions (No_Elaboration_Code); 2. package TestNECAMsg is 3. type Empty is interface; | >>> violation of restriction "No_Elaboration_Code" at line 1 4. end; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-01-06 Robert Dewar <de...@adacore.com> * sem_prag.adb (Analyze_Pragma, case No_Elaboration_Code_All): Do not set restriction No_Elaboration_Code unless the pragma appears in the main unit).
Index: sem_prag.adb =================================================================== --- sem_prag.adb (revision 219227) +++ sem_prag.adb (working copy) @@ -16783,9 +16783,11 @@ Set_No_Elab_Code_All (Current_Sem_Unit); - -- Set restriction No_Elaboration_Code + -- Set restriction No_Elaboration_Code if this is the main unit - Set_Restriction (No_Elaboration_Code, N); + if Current_Sem_Unit = Main_Unit then + Set_Restriction (No_Elaboration_Code, N); + end if; -- If we are in the main unit or in an extended main source unit, -- then we also add it to the configuration restrictions so that