There are three kinds of units that require code generation: the main unit, its corresponding spec and generic instances needed by the main unit. Previously the main unit and its corresponding spec were flagged as requiring code generation just before calling the backend, while instance units were flagged while they were created, which was inconsistent. Now all of them are flagged as soon as they are created, which both appears to be simpler and makes the Generate_Code flag valid all the time. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * gnat1drv.adb (Gnat1drv): Remove flagging of main unit and its corresponding spec as requiring code generation; now the flags are set much earlier. * lib-load.adb (Load_Main_Source): Set Generate_Code flag on the main unit source. (Make_Instance_Unit): Copy Generate_Code flag from the main unit to instance units. * lib-writ.adb (Write_ALI): Remove redundant condition; Generate_Code flag is always set for the main unit. * par-load.adb (Load): Set Generate_Code flag on the main unit's corresponding spec, if any.