diff options
author | Robert Dewar <dewar@adacore.com> | 2014-08-04 10:46:25 +0000 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2014-08-04 12:46:25 +0200 |
commit | 7401428337943079104e576e310bd0653dcf1d2d (patch) | |
tree | 5b3b1ed131c177e7f63281041f2faf7a7edb8522 /gcc/ada | |
parent | 536a2daf12f6a3c969f2b0df3a18ed9a985b817d (diff) | |
download | gcc-7401428337943079104e576e310bd0653dcf1d2d.zip gcc-7401428337943079104e576e310bd0653dcf1d2d.tar.gz gcc-7401428337943079104e576e310bd0653dcf1d2d.tar.bz2 |
exp_attr.adb (Expand_N_Attribute_Reference): Make sure prefix of constructed 'Valid attribute in -gnatVa mode does not...
2014-08-04 Robert Dewar <dewar@adacore.com>
* exp_attr.adb (Expand_N_Attribute_Reference): Make sure prefix
of constructed 'Valid attribute in -gnatVa mode does not appear
to come from source.
* sem_attr.adb (Analyze_Access_Attribute): Don't set
Never_Set_In_Source for non-source reference.
* sem_util.adb: Minor reformatting.
* sem_warn.adb (Check_References): Don't check Address_Taken,
not necessary, see comment.
From-SVN: r213568
Diffstat (limited to 'gcc/ada')
-rw-r--r-- | gcc/ada/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/ada/exp_attr.adb | 10 | ||||
-rw-r--r-- | gcc/ada/sem_attr.adb | 8 | ||||
-rw-r--r-- | gcc/ada/sem_util.adb | 3 | ||||
-rw-r--r-- | gcc/ada/sem_warn.adb | 6 |
5 files changed, 32 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0d70e1b..ea25404 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,16 @@ 2014-08-04 Robert Dewar <dewar@adacore.com> + * exp_attr.adb (Expand_N_Attribute_Reference): Make sure prefix + of constructed 'Valid attribute in -gnatVa mode does not appear + to come from source. + * sem_attr.adb (Analyze_Access_Attribute): Don't set + Never_Set_In_Source for non-source reference. + * sem_util.adb: Minor reformatting. + * sem_warn.adb (Check_References): Don't check Address_Taken, + not necessary, see comment. + +2014-08-04 Robert Dewar <dewar@adacore.com> + * sem_util.adb, sem_case.adb: Minor reformatting. 2014-08-04 Ed Schonberg <schonberg@adacore.com> diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index f9c1745..d2cd8e4 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -6448,13 +6448,19 @@ package body Exp_Attr is end if; -- We now have an object of the proper endianness and - -- alignment, and can call the Valid runtime routine. + -- alignment, and can construct a Valid attribute. + + -- We make sure the prefix of this valid attribute is + -- marked as not coming from source, to avoid losing + -- warnings from 'Valid looking like a possible update. + + Set_Comes_From_Source (Pref, False); Expand_Fpt_Attribute (N, Pkg, Name_Valid, New_List ( Make_Attribute_Reference (Loc, - Prefix => Unchecked_Convert_To (Ftp, Pref), + Prefix => Unchecked_Convert_To (Ftp, Pref), Attribute_Name => Name_Unrestricted_Access))); end case; diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index aecb69a..cdb3cfe 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -1005,7 +1005,13 @@ package body Sem_Attr is -- pointer can be used to modify the variable, and we might -- not detect this, leading to some junk warnings. - Set_Never_Set_In_Source (Ent, False); + -- We only do this for source references, since otherwise + -- we can suppress warnings, e.g. from the unrestricted + -- access generated for validity checks in -gnatVa mode. + + if Comes_From_Source (N) then + Set_Never_Set_In_Source (Ent, False); + end if; -- Mark entity as address taken, and kill current values diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index dd6206d..832c320 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -14557,8 +14557,7 @@ package body Sem_Util is -- this modifies a constant, then give an appropriate warning. if Overlays_Constant (Ent) - and then Modification_Comes_From_Source - and then Sure + and then (Modification_Comes_From_Source and Sure) then declare A : constant Node_Id := Address_Clause (Ent); diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index d52e2d7..e8c8f0b 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -1110,11 +1110,15 @@ package body Sem_Warn is -- since a given instance could have modifications outside -- the package. + -- Note that we used to check Address_Taken here, but we don't + -- want to do that since it can be set for non-source cases, + -- e.g. the Unrestricted_Access from a valid attribute, and + -- the wanted effect is included in Never_Set_In_Source. + elsif Warn_On_Constant and then (Ekind (E1) = E_Variable and then Has_Initial_Value (E1)) and then Never_Set_In_Source_Check_Spec (E1) - and then not Address_Taken (E1) and then not Generic_Package_Spec_Entity (E1) then -- A special case, if this variable is volatile and not |