aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2018-07-16 14:10:08 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-07-16 14:10:08 +0000
commit97710dc73178bb3a45712d69c9dcefc66bc3fb5f (patch)
tree22e93ac7ae7777537913328cc88569b95a66f744
parent4bde5d8c904df3ab4541e1df47c3916c97135124 (diff)
downloadgcc-97710dc73178bb3a45712d69c9dcefc66bc3fb5f.zip
gcc-97710dc73178bb3a45712d69c9dcefc66bc3fb5f.tar.gz
gcc-97710dc73178bb3a45712d69c9dcefc66bc3fb5f.tar.bz2
[Ada] Fix expansion of 'Count in protected types
2018-07-16 Javier Miranda <miranda@adacore.com> gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference ['Count]): Do not transform 'Count into a function call if the current scope has been eliminated. From-SVN: r262703
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/exp_attr.adb10
2 files changed, 16 insertions, 0 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index bcf2262..5e2ae1f 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2018-07-16 Javier Miranda <miranda@adacore.com>
+ * exp_attr.adb (Expand_N_Attribute_Reference ['Count]): Do not
+ transform 'Count into a function call if the current scope has been
+ eliminated.
+
+2018-07-16 Javier Miranda <miranda@adacore.com>
+
* sem_util.ads, sem_util.adb (Has_Prefix): Move this function to the
public part of this package.
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 30d6605..45c12bf 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -3049,6 +3049,16 @@ package body Exp_Attr is
-- Protected case
if Is_Protected_Type (Conctyp) then
+
+ -- No need to transform 'Count into a function call if the current
+ -- scope has been eliminated. In this case such transformation is
+ -- also not viable because the enclosing protected object is not
+ -- available.
+
+ if Is_Eliminated (Current_Scope) then
+ return;
+ end if;
+
case Corresponding_Runtime_Package (Conctyp) is
when System_Tasking_Protected_Objects_Entries =>
Name := New_Occurrence_Of (RTE (RE_Protected_Count), Loc);