Commit 0c3f76ba by Arnaud Charlet

[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
parent f3e0f7c3
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.
2016-07-04 Bob Duff <duff@adacore.com> 2016-07-04 Bob Duff <duff@adacore.com>
* sem_attr.adb (Eval_Attribute): The code was assuming * sem_attr.adb (Eval_Attribute): The code was assuming
......
...@@ -1354,14 +1354,17 @@ package body Sem_Attr is ...@@ -1354,14 +1354,17 @@ package body Sem_Attr is
-- The aspect or pragma where the attribute resides should be -- The aspect or pragma where the attribute resides should be
-- associated with a subprogram declaration or a body. If this is not -- associated with a subprogram declaration or a body. If this is not
-- the case, then the aspect or pragma is illegal. Return as analysis -- 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, if not Nkind_In (Subp_Decl, N_Abstract_Subprogram_Declaration,
N_Entry_Declaration, N_Entry_Declaration,
N_Generic_Subprogram_Declaration, N_Generic_Subprogram_Declaration,
N_Subprogram_Body, N_Subprogram_Body,
N_Subprogram_Body_Stub, N_Subprogram_Body_Stub,
N_Subprogram_Declaration) N_Subprogram_Declaration,
N_Subprogram_Renaming_Declaration)
then then
return; return;
end if; end if;
...@@ -7427,11 +7430,12 @@ package body Sem_Attr is ...@@ -7427,11 +7430,12 @@ package body Sem_Attr is
declare declare
Enum_Expr : Node_Id; Enum_Expr : Node_Id;
-- The enumeration-type expression of interest -- The enumeration-type expression of interest
begin begin
-- P'Enum_Rep case -- P'Enum_Rep case
if Ekind_In if Ekind_In (Entity (P), E_Constant,
(Entity (P), E_Constant, E_Enumeration_Literal) E_Enumeration_Literal)
then then
Enum_Expr := P; Enum_Expr := P;
...@@ -7449,7 +7453,8 @@ package body Sem_Attr is ...@@ -7449,7 +7453,8 @@ package body Sem_Attr is
end if; end if;
-- We can fold if the expression is an enumeration -- 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 if Nkind (Enum_Expr) in N_Has_Entity
and then (Ekind (Entity (Enum_Expr)) = and then (Ekind (Entity (Enum_Expr)) =
...@@ -7458,7 +7463,7 @@ package body Sem_Attr is ...@@ -7458,7 +7463,7 @@ package body Sem_Attr is
(Ekind (Entity (Enum_Expr)) = E_Constant (Ekind (Entity (Enum_Expr)) = E_Constant
and then Nkind (Parent (Entity (Enum_Expr))) = and then Nkind (Parent (Entity (Enum_Expr))) =
N_Object_Declaration N_Object_Declaration
and then Is_Static_Expression and then Compile_Time_Known_Value
(Expression (Parent (Entity (P)))))) (Expression (Parent (Entity (P))))))
then then
P_Entity := Etype (P); P_Entity := Etype (P);
......
...@@ -1937,9 +1937,11 @@ package body Sem_Ch13 is ...@@ -1937,9 +1937,11 @@ package body Sem_Ch13 is
if not Implementation_Defined_Aspect (A_Id) then if not Implementation_Defined_Aspect (A_Id) then
Error_Msg_Name_1 := Nam; Error_Msg_Name_1 := Nam;
-- Not allowed for renaming declarations -- Not allowed for renaming declarations. Examine original
-- node because a subprogram renaming may have been rewritten
-- as a body.
if Nkind (N) in N_Renaming_Declaration then if Nkind (Original_Node (N)) in N_Renaming_Declaration then
Error_Msg_N Error_Msg_N
("aspect % not allowed for renaming declaration", ("aspect % not allowed for renaming declaration",
Aspect); Aspect);
......
...@@ -31,6 +31,7 @@ with Errout; use Errout; ...@@ -31,6 +31,7 @@ with Errout; use Errout;
with Fname; use Fname; with Fname; use Fname;
with Lib; use Lib; with Lib; use Lib;
with Namet; use Namet; with Namet; use Namet;
with Opt; use Opt;
with Sem_Aux; use Sem_Aux; with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval; with Sem_Eval; use Sem_Eval;
with Sem_Util; use Sem_Util; with Sem_Util; use Sem_Util;
...@@ -466,8 +467,13 @@ package body Sem_Intr is ...@@ -466,8 +467,13 @@ package body Sem_Intr is
procedure Errint (Msg : String; S : Node_Id; N : Node_Id) is procedure Errint (Msg : String; S : Node_Id; N : Node_Id) is
begin begin
Error_Msg_N (Msg, S); -- Ignore errors on Intrinsic in Relaxed_RM_Semantics mode where we can
Error_Msg_N ("incorrect intrinsic subprogram, see spec", N); -- be more liberal.
if not Relaxed_RM_Semantics then
Error_Msg_N (Msg, S);
Error_Msg_N ("incorrect intrinsic subprogram, see spec", N);
end if;
end Errint; end Errint;
end Sem_Intr; end Sem_Intr;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment