aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_attr.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2016-07-04 14:32:22 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2016-07-04 14:32:22 +0200
commit0c3f76bac4d10283ab9d6fc9a64ccb0140a0b91e (patch)
treec87cbe44a1dfabcbe30a880e6d790dd9b0925b5b /gcc/ada/sem_attr.adb
parentf3e0f7c3c189b07f56e8758ab5174bd2820d7ea5 (diff)
downloadgcc-0c3f76bac4d10283ab9d6fc9a64ccb0140a0b91e.zip
gcc-0c3f76bac4d10283ab9d6fc9a64ccb0140a0b91e.tar.gz
gcc-0c3f76bac4d10283ab9d6fc9a64ccb0140a0b91e.tar.bz2
[multiple changes]
2016-07-04 Ed Schonberg <schonberg@adacore.com> * sem_attr.adb (Analyze_Attribute_Old_Result): The attributes can appear in the postcondition of a subprogram renaming declaration, when the renamed entity is an attribute reference that is a function (such as 'Value). * sem_attr.adb (Eval_Attribute): It doesn't need to be static, just known at compile time, so use Compile_Time_Known_Value instead of Is_Static_Expression. This is an efficiency improvement over the previous bug fix. * sem_ch13.adb (Analyze_One_Aspect): Use Original_Node to detect illegal aspects on subprogram renaming declarations that may have been rewritten as bodies. 2016-07-04 Arnaud Charlet <charlet@adacore.com> * sem_intr.adb (Errint): Do not emit error message in Relaxed_RM_Semantics mode. From-SVN: r237976
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r--gcc/ada/sem_attr.adb17
1 files changed, 11 insertions, 6 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 389f830..d6d8509 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1354,14 +1354,17 @@ package body Sem_Attr is
-- The aspect or pragma where the attribute resides should be
-- associated with a subprogram declaration or a body. If this is not
-- the case, then the aspect or pragma is illegal. Return as analysis
- -- cannot be carried out.
+ -- cannot be carried out. Note that it is legal to have the aspect
+ -- appear on a subprogram renaming, when the renamed entity is an
+ -- attribute reference.
if not Nkind_In (Subp_Decl, N_Abstract_Subprogram_Declaration,
N_Entry_Declaration,
N_Generic_Subprogram_Declaration,
N_Subprogram_Body,
N_Subprogram_Body_Stub,
- N_Subprogram_Declaration)
+ N_Subprogram_Declaration,
+ N_Subprogram_Renaming_Declaration)
then
return;
end if;
@@ -7427,11 +7430,12 @@ package body Sem_Attr is
declare
Enum_Expr : Node_Id;
-- The enumeration-type expression of interest
+
begin
-- P'Enum_Rep case
- if Ekind_In
- (Entity (P), E_Constant, E_Enumeration_Literal)
+ if Ekind_In (Entity (P), E_Constant,
+ E_Enumeration_Literal)
then
Enum_Expr := P;
@@ -7449,7 +7453,8 @@ package body Sem_Attr is
end if;
-- We can fold if the expression is an enumeration
- -- literal, or if it denotes a static constant.
+ -- literal, or if it denotes a constant whose value
+ -- is known at compile time.
if Nkind (Enum_Expr) in N_Has_Entity
and then (Ekind (Entity (Enum_Expr)) =
@@ -7458,7 +7463,7 @@ package body Sem_Attr is
(Ekind (Entity (Enum_Expr)) = E_Constant
and then Nkind (Parent (Entity (Enum_Expr))) =
N_Object_Declaration
- and then Is_Static_Expression
+ and then Compile_Time_Known_Value
(Expression (Parent (Entity (P))))))
then
P_Entity := Etype (P);