The compiler warns when a variable overlays a constant because of an address clause on the former. This change makes the compiler issue the same warning when a non-imported constant overlays a constant. The patch also removes an old pessimization whereby overlaid objects would be treated as volatile by the compiler in some circumstances, for example preventing them from being put into read-only memory if they are constant. The compiler must issue the warning: consovl3.adb:4:03: warning: constant "C" may be modified via address clause at line 5 on the followig code: with Q; use Q; procedure Consovl3 is A : constant Natural := 0; for A'Address use C'Address; begin null; end; package Q is C : constant Natural := 1; end Q; Tested on x86_64-pc-linux-gnu, committed on trunk 2015-11-12 Eric Botcazou <ebotcazou@adacore.com> * einfo.ads (Overlays_Constant): Document usage for E_Constant. * freeze.adb (Warn_Overlay): Small reformatting. (Check_Address_Clause): Deal specifically with deferred constants. For a variable or a non-imported constant overlaying a constant object and with initialization value, either remove the initialization or issue a warning. Fix a couple of typos. * sem_util.adb (Note_Possible_Modification): Overhaul the condition for the warning on modified constants and use Find_Overlaid_Entity instead of doing it manually. * sem_ch13.adb (Analyze_Attribute_Definition_Clause): Compute and set Overlays_Constant once on entry. Do not treat the overlaid entity as volatile. Do not issue the warning on modified constants here. * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Constant>: Remove over-restrictive condition for the special treatment of deferred constants. <E_Variable>: Remove obsolete associated code.