Commit 48b0da2d by Arnaud Charlet

[multiple changes]

2015-01-30  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_attr.adb (Analyze_Attribute): Ensure that
	the check concerning Refined_Post takes precedence over the
	other cases.

2015-01-30  Gary Dismukes  <dismukes@adacore.com>

	* sem_prag.adb: Minor typo fixes and reformatting.

From-SVN: r220282
parent 95d0610c
2015-01-30 Hristian Kirtchev <kirtchev@adacore.com>
* sem_attr.adb (Analyze_Attribute): Ensure that
the check concerning Refined_Post takes precedence over the
other cases.
2015-01-30 Gary Dismukes <dismukes@adacore.com>
* sem_prag.adb: Minor typo fixes and reformatting.
2015-01-30 Yannick Moy <moy@adacore.com>
* sem_attr.adb: Code clean up.
......
......@@ -4572,6 +4572,32 @@ package body Sem_Attr is
CS := Scope (CS);
end loop;
-- Check the legality of attribute 'Old when it appears inside pragma
-- Refined_Post. These specialized checks are required only when code
-- generation is disabled. In the general case pragma Refined_Post is
-- transformed into pragma Check by Process_PPCs which in turn is
-- relocated to procedure _Postconditions. From then on the legality
-- of 'Old is determined as usual.
if not Expander_Active and then In_Refined_Post then
Preanalyze_And_Resolve (P);
Check_References_In_Prefix (CS);
P_Type := Etype (P);
Set_Etype (N, P_Type);
if Is_Limited_Type (P_Type) then
Error_Attr ("attribute % cannot apply to limited objects", P);
end if;
if Is_Entity_Name (P)
and then Is_Constant_Object (Entity (P))
then
Error_Msg_N
("??attribute Old applied to constant has no effect", P);
end if;
return;
-- A Contract_Cases, Postcondition or Test_Case pragma is in the
-- process of being preanalyzed. Perform the semantic checks now
-- before the pragma is relocated and/or expanded.
......@@ -4579,7 +4605,7 @@ package body Sem_Attr is
-- For a generic subprogram, postconditions are preanalyzed as well
-- for name capture, and still appear within an aspect spec.
if In_Spec_Expression or Inside_A_Generic then
elsif In_Spec_Expression or Inside_A_Generic then
Prag := N;
while Present (Prag)
and then not Nkind_In (Prag, N_Aspect_Specification,
......@@ -4625,32 +4651,6 @@ package body Sem_Attr is
end case;
end if;
-- Check the legality of attribute 'Old when it appears inside pragma
-- Refined_Post. These specialized checks are required only when code
-- generation is disabled. In the general case pragma Refined_Post is
-- transformed into pragma Check by Process_PPCs which in turn is
-- relocated to procedure _Postconditions. From then on the legality
-- of 'Old is determined as usual.
elsif not Expander_Active and then In_Refined_Post then
Preanalyze_And_Resolve (P);
Check_References_In_Prefix (CS);
P_Type := Etype (P);
Set_Etype (N, P_Type);
if Is_Limited_Type (P_Type) then
Error_Attr ("attribute % cannot apply to limited objects", P);
end if;
if Is_Entity_Name (P)
and then Is_Constant_Object (Entity (P))
then
Error_Msg_N
("??attribute Old applied to constant has no effect", P);
end if;
return;
-- Body case, where we must be inside a generated _Postconditions
-- procedure, or else the attribute use is definitely misplaced. The
-- postcondition itself may have generated transient scopes, and is
......
......@@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2014, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
......@@ -17846,8 +17846,8 @@ package body Sem_Prag is
or else (Is_Generic_Type (Ent) and then Is_Derived_Type (Ent))
-- AI05-0028: The pragma applies to all composite types. Note
-- that we apply this binding intepretation to previous verions
-- of Ada so there is no Ada 2012 guard. Seems a reasonable
-- that we apply this binding interpretation to earlier versions
-- of Ada, so there is no Ada 2012 guard. Seems a reasonable
-- choice since there are other compilers that do the same.
or else Is_Composite_Type (Ent)
......
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