aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/restrict.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2011-11-21 12:35:55 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2011-11-21 12:35:55 +0100
commita4901c083549b9173a1cb3e55741ef0dfc3a8472 (patch)
tree59878b2aee8b9ef9f117c9edec77057d4c951fc7 /gcc/ada/restrict.adb
parent4bf201ed2f9a1c163a02eae24a99440d2790e192 (diff)
downloadgcc-a4901c083549b9173a1cb3e55741ef0dfc3a8472.zip
gcc-a4901c083549b9173a1cb3e55741ef0dfc3a8472.tar.gz
gcc-a4901c083549b9173a1cb3e55741ef0dfc3a8472.tar.bz2
sem_ch6.adb (Is_Public_Subprogram_For): New procedure
2011-11-21 Robert Dewar <dewar@adacore.com> * sem_ch6.adb (Is_Public_Subprogram_For): New procedure (Process_PPCs): Invariants only apply to public subprograms. 2011-11-21 Robert Dewar <dewar@adacore.com> * sem_util.adb, sem_util.ads, sem_attr.adb, restrict.adb, restrict.ads: Fix for No_Implicit_Aliasing in the renames case. 2011-11-21 Robert Dewar <dewar@adacore.com> * a-finali.ads: Use pragma Pure_12 for this unit * aspects.adb: Add aspect Pure_12 * aspects.ads: Add aspect Pure_12 * opt.ads: Add note on Pure_12 * par-prag.adb: Add dummy entry for Pure_12 * sem_prag.adb: Implement Pure_12 pragma * snames.ads-tmpl: Add Entry for Pure_12 2011-11-21 Sergey Rybin <rybin@adacore.com frybin> * vms_data.ads: Add qualifiers for new gnatpp options '--call_threshold' and '--par_threshold". * gnat_ugn.texi: Add description for new gnatpp options '--call_threshold' and '--par_threshold". 2011-11-21 Robert Dewar <dewar@adacore.com> * lib.ads: Minor reformatting. 2011-11-21 Robert Dewar <dewar@adacore.com> * lib-load.ads: Add comment. From-SVN: r181563
Diffstat (limited to 'gcc/ada/restrict.adb')
-rw-r--r--gcc/ada/restrict.adb72
1 files changed, 72 insertions, 0 deletions
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb
index 813568d..399547c 100644
--- a/gcc/ada/restrict.adb
+++ b/gcc/ada/restrict.adb
@@ -183,6 +183,78 @@ package body Restrict is
end if;
end Check_SPARK_Restriction;
+ --------------------------------
+ -- Check_No_Implicit_Aliasing --
+ --------------------------------
+
+ procedure Check_No_Implicit_Aliasing (Obj : Node_Id) is
+ E : Entity_Id;
+
+ begin
+ -- If restriction not active, nothing to check
+
+ if not Restriction_Active (No_Implicit_Aliasing) then
+ return;
+ end if;
+
+ -- If we have an entity name, check entity
+
+ if Is_Entity_Name (Obj) then
+ E := Entity (Obj);
+
+ -- Restriction applies to entities that are objects
+
+ if Is_Object (E) then
+ if Is_Aliased (E) then
+ return;
+
+ elsif Present (Renamed_Object (E)) then
+ Check_No_Implicit_Aliasing (Renamed_Object (E));
+ return;
+ end if;
+
+ -- If we don't have an object, then it's OK
+
+ else
+ return;
+ end if;
+
+ -- For selected component, check selector
+
+ elsif Nkind (Obj) = N_Selected_Component then
+ Check_No_Implicit_Aliasing (Selector_Name (Obj));
+ return;
+
+ -- Indexed component is OK if aliased components
+
+ elsif Nkind (Obj) = N_Indexed_Component then
+ if Has_Aliased_Components (Etype (Prefix (Obj)))
+ or else
+ (Is_Access_Type (Etype (Prefix (Obj)))
+ and then Has_Aliased_Components
+ (Designated_Type (Etype (Prefix (Obj)))))
+ then
+ return;
+ end if;
+
+ -- For type conversion, check converted expression
+
+ elsif Nkind_In (Obj, N_Unchecked_Type_Conversion, N_Type_Conversion) then
+ Check_No_Implicit_Aliasing (Expression (Obj));
+ return;
+
+ -- Explicit dereference is always OK
+
+ elsif Nkind (Obj) = N_Explicit_Dereference then
+ return;
+ end if;
+
+ -- If we fall through, then we have an aliased view that does not meet
+ -- the rules for being explicitly aliased, so issue restriction msg.
+
+ Check_Restriction (No_Implicit_Aliasing, Obj);
+ end Check_No_Implicit_Aliasing;
+
-----------------------------------------
-- Check_Implicit_Dynamic_Code_Allowed --
-----------------------------------------