For iterator specification appearing inside an iterated component association, we just did ad-hoc, incomplete checks and delayed a proper analysis until the iterated component association is expanded into loop (and then reanalyzed). However, when the iterated component association is not expanded, e.g. because we are in semantic checking mode, GNATprove mode or inside a generic, then the AST lacked any processing or error reporting. This is fixed by reusing the existing analysis of iterator specifications, as they also appear in other constructs, e.g. in quantified expressions. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_aggr.adb (Resolve_Iterated_Component_Association): Split processing of cases with and without iterator specification; reuse analysis of iterator specification; improve diagnostics for premature usage of iterator index in discrete choices.