In CodePeer mode attribute Image is not expanded and has its Etype set as the unconstrained String type. When this attribute appears as a prefix of an indexed component, we get a check; when it appears as a prefix of a slice, we don't get a check. For indexed components, the check effectively comes from Apply_Scalar_Range_Check, where prefixes of unconstrained array types are handled specifically. For slices, the seemingly similar routine Apply_Range_Check doesn't specifically handle such prefixes. Instead, we need to give this routine a constrained subtype, just like we do when slice is prefixed with a call to a function that returns an unconstrained array. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * sem_res.adb (Resolve_Slice): Add custom handling of attribute Image and similar in CodePeer mode. This complements the existing custom handling of these attributes in Expand_N_Attribute_Reference.