summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorcharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-15 09:07:53 +0000
committercharlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4>2012-03-15 09:07:53 +0000
commitdefed25de48dc6b3a963f7dc18529f63a5b9357e (patch)
treef08e18d678f1252132c0e9fe308b4ac8aa5036e3 /gcc
parent469bbc181632d0bf02cb62cd04013e26457bc5d5 (diff)
downloadgcc-defed25de48dc6b3a963f7dc18529f63a5b9357e.tar.gz
2012-03-15 Robert Dewar <dewar@adacore.com>
* sem_prag.adb, sem_prag.ads, sem_util.ads, sem_attr.adb, sem_ch6.adb, sem_warn.adb: Minor reformatting. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@185418 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_attr.adb17
-rw-r--r--gcc/ada/sem_ch6.adb100
-rw-r--r--gcc/ada/sem_prag.adb470
-rw-r--r--gcc/ada/sem_prag.ads16
-rw-r--r--gcc/ada/sem_util.ads1
-rw-r--r--gcc/ada/sem_warn.adb3
7 files changed, 307 insertions, 305 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index e8d4a5b2ad1..c9063a650f0 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2012-03-15 Robert Dewar <dewar@adacore.com>
+
+ * sem_prag.adb, sem_prag.ads, sem_util.ads, sem_attr.adb, sem_ch6.adb,
+ sem_warn.adb: Minor reformatting.
+
2012-03-15 Hristian Kirtchev <kirtchev@adacore.com>
* exp_util.adb (Initialized_By_Ctrl_Function): Do not loop over
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index c5ad305a407..d5164865df4 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -1122,9 +1122,7 @@ package body Sem_Attr is
-- Case of a subtype mark
- if Is_Entity_Name (P)
- and then Is_Type (Entity (P))
- then
+ if Is_Entity_Name (P) and then Is_Type (Entity (P)) then
return;
end if;
@@ -1134,13 +1132,13 @@ package body Sem_Attr is
if Is_Access_Type (P_Type) then
- -- If there is an implicit dereference, then we must freeze
- -- the designated type of the access type, since the type of
- -- the referenced array is this type (see AI95-00106).
+ -- If there is an implicit dereference, then we must freeze the
+ -- designated type of the access type, since the type of the
+ -- referenced array is this type (see AI95-00106).
-- As done elsewhere, freezing must not happen when pre-analyzing
- -- a pre- or postcondition or a default value for an object or
- -- for a formal parameter.
+ -- a pre- or postcondition or a default value for an object or for
+ -- a formal parameter.
if not In_Spec_Expression then
Freeze_Before (N, Designated_Type (P_Type));
@@ -4257,7 +4255,8 @@ package body Sem_Attr is
P);
elsif Get_Pragma_Id (Prag) = Pragma_Contract_Case
- or else Get_Pragma_Id (Prag) = Pragma_Test_Case
+ or else
+ Get_Pragma_Id (Prag) = Pragma_Test_Case
then
declare
Arg_Ens : constant Node_Id :=
diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb
index 13fc5aba172..391ac8034e5 100644
--- a/gcc/ada/sem_ch6.adb
+++ b/gcc/ada/sem_ch6.adb
@@ -7076,7 +7076,6 @@ package body Sem_Ch6 is
begin
Prag := Spec_CTC_List (Contract (Spec));
-
loop
-- Retrieve the Ensures component of the contract-case, if any
@@ -7130,19 +7129,15 @@ package body Sem_Ch6 is
begin
Prag := Spec_PPC_List (Contract (Spec));
-
loop
Arg := First (Pragma_Argument_Associations (Prag));
if Pragma_Name (Prag) = Name_Postcondition then
-- Since pre- and post-conditions are listed in reverse order,
- -- the first postcondition in the list is the last in the
- -- source.
+ -- the first postcondition in the list is last in the source.
- if not Class
- and then No (Last_Postcondition)
- then
+ if not Class and then No (Last_Postcondition) then
Last_Postcondition := Prag;
end if;
@@ -7161,8 +7156,8 @@ package body Sem_Ch6 is
Ignored := Find_Post_State (Arg);
if not Post_State_Mentioned then
- Error_Msg_N ("?postcondition refers only to pre-state",
- Prag);
+ Error_Msg_N
+ ("?postcondition refers only to pre-state", Prag);
end if;
end if;
end if;
@@ -7208,7 +7203,7 @@ package body Sem_Ch6 is
if Ekind_In (Spec_Id, E_Function, E_Generic_Function)
and then (Present (Last_Postcondition)
- or else Present (Last_Contract_Case))
+ or else Present (Last_Contract_Case))
and then not Attribute_Result_Mentioned
then
if Present (Last_Postcondition) then
@@ -11045,17 +11040,16 @@ package body Sem_Ch6 is
-------------
function Grab_CC return Node_Id is
+ Loc : constant Source_Ptr := Sloc (Prag);
CP : Node_Id;
Req : Node_Id;
Ens : Node_Id;
Post : Node_Id;
- Loc : constant Source_Ptr := Sloc (Prag);
- -- Similarly to postcondition, the string is "failed xx from yy"
- -- where xx is in all lower case. The reason for this different
- -- wording compared to other Check cases is that the failure is not
- -- at the point of occurrence of the pragma, unlike the other Check
- -- cases.
+ -- As with postcondition, the string is "failed xx from yy" where
+ -- xx is in all lower case. The reason for this different wording
+ -- compared to other Check cases is that the failure is not at the
+ -- point of occurrence of the pragma, unlike the other Check cases.
Msg : constant String :=
"failed contract case from " & Build_Location_String (Loc);
@@ -11063,57 +11057,60 @@ package body Sem_Ch6 is
begin
-- Copy the Requires and Ensures expressions
- Req := New_Copy_Tree (
- Expression (Get_Requires_From_Case_Pragma (Prag)),
- New_Scope => Current_Scope);
+ Req := New_Copy_Tree
+ (Expression (Get_Requires_From_Case_Pragma (Prag)),
+ New_Scope => Current_Scope);
- Ens := New_Copy_Tree (
- Expression (Get_Ensures_From_Case_Pragma (Prag)),
- New_Scope => Current_Scope);
+ Ens := New_Copy_Tree
+ (Expression (Get_Ensures_From_Case_Pragma (Prag)),
+ New_Scope => Current_Scope);
-- Build the postcondition (not Requires'Old or else Ensures)
- Post := Make_Or_Else (Loc,
- Left_Opnd => Make_Op_Not (Loc,
- Make_Attribute_Reference (Loc,
- Prefix => Req,
- Attribute_Name => Name_Old)),
- Right_Opnd => Ens);
+ Post :=
+ Make_Or_Else (Loc,
+ Left_Opnd =>
+ Make_Op_Not (Loc,
+ Make_Attribute_Reference (Loc,
+ Prefix => Req,
+ Attribute_Name => Name_Old)),
+ Right_Opnd => Ens);
-- For a contract case pragma within a generic, generate a
-- postcondition pragma for later expansion. This is also used
-- when an error was detected, thus setting Expander_Active to False.
if not Expander_Active then
- CP := Make_Pragma (Loc,
- Chars => Name_Postcondition,
- Pragma_Argument_Associations => New_List (
- Make_Pragma_Argument_Association (Loc,
- Chars => Name_Check,
- Expression => Post),
-
- Make_Pragma_Argument_Association (Loc,
- Chars => Name_Message,
- Expression => Make_String_Literal (Loc, Msg))));
+ CP :=
+ Make_Pragma (Loc,
+ Chars => Name_Postcondition,
+ Pragma_Argument_Associations => New_List (
+ Make_Pragma_Argument_Association (Loc,
+ Chars => Name_Check,
+ Expression => Post),
+
+ Make_Pragma_Argument_Association (Loc,
+ Chars => Name_Message,
+ Expression => Make_String_Literal (Loc, Msg))));
-- Otherwise, create the Check pragma
else
- CP := Make_Pragma (Loc,
- Chars => Name_Check,
- Pragma_Argument_Associations => New_List (
- Make_Pragma_Argument_Association (Loc,
- Chars => Name_Name,
- Expression =>
- Make_Identifier (Loc, Name_Postcondition)),
+ CP :=
+ Make_Pragma (Loc,
+ Chars => Name_Check,
+ Pragma_Argument_Associations => New_List (
+ Make_Pragma_Argument_Association (Loc,
+ Chars => Name_Name,
+ Expression => Make_Identifier (Loc, Name_Postcondition)),
- Make_Pragma_Argument_Association (Loc,
- Chars => Name_Check,
- Expression => Post),
+ Make_Pragma_Argument_Association (Loc,
+ Chars => Name_Check,
+ Expression => Post),
- Make_Pragma_Argument_Association (Loc,
- Chars => Name_Message,
- Expression => Make_String_Literal (Loc, Msg))));
+ Make_Pragma_Argument_Association (Loc,
+ Chars => Name_Message,
+ Expression => Make_String_Literal (Loc, Msg))));
end if;
-- Return the Postcondition or Check pragma
@@ -11534,7 +11531,6 @@ package body Sem_Ch6 is
Prag := Next_Pragma (Prag);
exit when No (Prag);
end loop;
-
end Process_Contract_Cases;
-----------------------------
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index aa574eea150..51ca907a381 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -244,6 +244,32 @@ package body Sem_Prag is
end Adjust_External_Name_Case;
------------------------------
+ -- Analyze_CTC_In_Decl_Part --
+ ------------------------------
+
+ procedure Analyze_CTC_In_Decl_Part (N : Node_Id; S : Entity_Id) is
+ begin
+ -- Install formals and push subprogram spec onto scope stack so that we
+ -- can see the formals from the pragma.
+
+ Install_Formals (S);
+ Push_Scope (S);
+
+ -- Preanalyze the boolean expressions, we treat these as spec
+ -- expressions (i.e. similar to a default expression).
+
+ Preanalyze_CTC_Args
+ (N,
+ Get_Requires_From_Case_Pragma (N),
+ Get_Ensures_From_Case_Pragma (N));
+
+ -- Remove the subprogram from the scope stack now that the pre-analysis
+ -- of the expressions in the contract case or test case is done.
+
+ End_Scope;
+ end Analyze_CTC_In_Decl_Part;
+
+ ------------------------------
-- Analyze_PPC_In_Decl_Part --
------------------------------
@@ -532,6 +558,18 @@ package body Sem_Prag is
-- UU_Typ is the related Unchecked_Union type. Flag In_Variant_Part
-- should be set when Comp comes from a record variant.
+ procedure Check_Contract_Or_Test_Case;
+ -- Called to process a contract-case or test-case pragma. It
+ -- starts with checking pragma arguments, and the rest of the
+ -- treatment is similar to the one for pre- and postcondition in
+ -- Check_Precondition_Postcondition, except the placement rules for the
+ -- contract-case and test-case pragmas are stricter. These pragmas may
+ -- only occur after a subprogram spec declared directly in a package
+ -- spec unit. In this case, the pragma is chained to the subprogram in
+ -- question (using Spec_CTC_List and Next_Pragma) and analysis of the
+ -- pragma is delayed till the end of the spec. In all other cases, an
+ -- error message for bad placement is given.
+
procedure Check_Duplicate_Pragma (E : Entity_Id);
-- Check if a pragma of the same name as the current pragma is already
-- chained as a rep pragma to the given entity. If so give a message
@@ -637,17 +675,6 @@ package body Sem_Prag is
-- that the constraint is static as required by the restrictions for
-- Unchecked_Union.
- procedure Check_Contract_Or_Test_Case;
- -- Called to process a contract-case or test-case pragma. The
- -- treatment is similar to the one for pre- and postcondition in
- -- Check_Precondition_Postcondition, except the placement rules for the
- -- contract-case and test-case pragmas are stricter. These pragmas may
- -- only occur after a subprogram spec declared directly in a package
- -- spec unit. In this case, the pragma is chained to the subprogram in
- -- question (using Spec_CTC_List and Next_Pragma) and analysis of the
- -- pragma is delayed till the end of the spec. In all other cases, an
- -- error message for bad placement is given.
-
procedure Check_Valid_Configuration_Pragma;
-- Legality checks for placement of a configuration pragma
@@ -1389,6 +1416,179 @@ package body Sem_Prag is
end if;
end Check_Component;
+ ---------------------------------
+ -- Check_Contract_Or_Test_Case --
+ ---------------------------------
+
+ procedure Check_Contract_Or_Test_Case is
+ P : Node_Id;
+ PO : Node_Id;
+
+ procedure Chain_CTC (PO : Node_Id);
+ -- If PO is a [generic] subprogram declaration node, then the
+ -- contract-case or test-case applies to this subprogram and the
+ -- processing for the pragma is completed. Otherwise the pragma
+ -- is misplaced.
+
+ ---------------
+ -- Chain_CTC --
+ ---------------
+
+ procedure Chain_CTC (PO : Node_Id) is
+ S : Entity_Id;
+
+ begin
+ if Nkind (PO) = N_Abstract_Subprogram_Declaration then
+ Error_Pragma
+ ("pragma% cannot be applied to abstract subprogram");
+
+ elsif Nkind (PO) = N_Entry_Declaration then
+ Error_Pragma ("pragma% cannot be applied to entry");
+
+ elsif not Nkind_In (PO, N_Subprogram_Declaration,
+ N_Generic_Subprogram_Declaration)
+ then
+ Pragma_Misplaced;
+ end if;
+
+ -- Here if we have [generic] subprogram declaration
+
+ S := Defining_Unit_Name (Specification (PO));
+
+ -- Note: we do not analyze the pragma at this point. Instead we
+ -- delay this analysis until the end of the declarative part in
+ -- which the pragma appears. This implements the required delay
+ -- in this analysis, allowing forward references. The analysis
+ -- happens at the end of Analyze_Declarations.
+
+ -- There should not be another contract-case or test-case with the
+ -- same name associated to this subprogram.
+
+ declare
+ Name : constant String_Id := Get_Name_From_Case_Pragma (N);
+ CTC : Node_Id;
+
+ begin
+ CTC := Spec_CTC_List (Contract (S));
+ while Present (CTC) loop
+ if String_Equal (Name, Get_Name_From_Case_Pragma (CTC)) then
+ Error_Msg_Sloc := Sloc (CTC);
+ Error_Pragma ("name for pragma% is already used#");
+ end if;
+
+ CTC := Next_Pragma (CTC);
+ end loop;
+ end;
+
+ -- Chain spec CTC pragma to list for subprogram
+
+ Set_Next_Pragma (N, Spec_CTC_List (Contract (S)));
+ Set_Spec_CTC_List (Contract (S), N);
+ end Chain_CTC;
+
+ -- Start of processing for Check_Contract_Or_Test_Case
+
+ begin
+ -- First check pragma arguments
+
+ GNAT_Pragma;
+ Check_At_Least_N_Arguments (2);
+ Check_At_Most_N_Arguments (4);
+ Check_Arg_Order
+ ((Name_Name, Name_Mode, Name_Requires, Name_Ensures));
+
+ Check_Optional_Identifier (Arg1, Name_Name);
+ Check_Arg_Is_Static_Expression (Arg1, Standard_String);
+
+ -- In ASIS mode, for a pragma generated from a source aspect, also
+ -- analyze the original aspect expression.
+
+ if ASIS_Mode
+ and then Present (Corresponding_Aspect (N))
+ then
+ Check_Expr_Is_Static_Expression
+ (Original_Node (Get_Pragma_Arg (Arg1)), Standard_String);
+ end if;
+
+ Check_Optional_Identifier (Arg2, Name_Mode);
+ Check_Arg_Is_One_Of (Arg2, Name_Nominal, Name_Robustness);
+
+ if Arg_Count = 4 then
+ Check_Identifier (Arg3, Name_Requires);
+ Check_Identifier (Arg4, Name_Ensures);
+
+ elsif Arg_Count = 3 then
+ Check_Identifier_Is_One_Of (Arg3, Name_Requires, Name_Ensures);
+ end if;
+
+ -- Check pragma placement
+
+ if not Is_List_Member (N) then
+ Pragma_Misplaced;
+ end if;
+
+ -- Contract-case or test-case should only appear in package spec unit
+
+ if Get_Source_Unit (N) = No_Unit
+ or else not Nkind_In (Sinfo.Unit (Cunit (Get_Source_Unit (N))),
+ N_Package_Declaration,
+ N_Generic_Package_Declaration)
+ then
+ Pragma_Misplaced;
+ end if;
+
+ -- Search prior declarations
+
+ P := N;
+ while Present (Prev (P)) loop
+ P := Prev (P);
+
+ -- If the previous node is a generic subprogram, do not go to to
+ -- the original node, which is the unanalyzed tree: we need to
+ -- attach the contract-case or test-case to the analyzed version
+ -- at this point. They get propagated to the original tree when
+ -- analyzing the corresponding body.
+
+ if Nkind (P) not in N_Generic_Declaration then
+ PO := Original_Node (P);
+ else
+ PO := P;
+ end if;
+
+ -- Skip past prior pragma
+
+ if Nkind (PO) = N_Pragma then
+ null;
+
+ -- Skip stuff not coming from source
+
+ elsif not Comes_From_Source (PO) then
+ null;
+
+ -- Only remaining possibility is subprogram declaration. First
+ -- check that it is declared directly in a package declaration.
+ -- This may be either the package declaration for the current unit
+ -- being defined or a local package declaration.
+
+ elsif not Present (Parent (Parent (PO)))
+ or else not Present (Parent (Parent (Parent (PO))))
+ or else not Nkind_In (Parent (Parent (PO)),
+ N_Package_Declaration,
+ N_Generic_Package_Declaration)
+ then
+ Pragma_Misplaced;
+
+ else
+ Chain_CTC (PO);
+ return;
+ end if;
+ end loop;
+
+ -- If we fall through, pragma was misplaced
+
+ Pragma_Misplaced;
+ end Check_Contract_Or_Test_Case;
+
----------------------------
-- Check_Duplicate_Pragma --
----------------------------
@@ -2114,162 +2314,6 @@ package body Sem_Prag is
end case;
end Check_Static_Constraint;
- ---------------------------------
- -- Check_Contract_Or_Test_Case --
- ---------------------------------
-
- procedure Check_Contract_Or_Test_Case is
- P : Node_Id;
- PO : Node_Id;
-
- procedure Chain_CTC (PO : Node_Id);
- -- If PO is a [generic] subprogram declaration node, then the
- -- contract-case or test-case applies to this subprogram and the
- -- processing for the pragma is completed. Otherwise the pragma
- -- is misplaced.
-
- ---------------
- -- Chain_CTC --
- ---------------
-
- procedure Chain_CTC (PO : Node_Id) is
- S : Entity_Id;
-
- begin
- if Nkind (PO) = N_Abstract_Subprogram_Declaration then
- if From_Aspect_Specification (N) then
- Error_Pragma
- ("aspect% cannot be applied to abstract subprogram");
- else
- Error_Pragma
- ("pragma% cannot be applied to abstract subprogram");
- end if;
-
- elsif Nkind (PO) = N_Entry_Declaration then
- if From_Aspect_Specification (N) then
- Error_Pragma ("aspect% cannot be applied to entry");
- else
- Error_Pragma ("pragma% cannot be applied to entry");
- end if;
-
- elsif not Nkind_In (PO, N_Subprogram_Declaration,
- N_Generic_Subprogram_Declaration)
- then
- Pragma_Misplaced;
- end if;
-
- -- Here if we have [generic] subprogram declaration
-
- S := Defining_Unit_Name (Specification (PO));
-
- -- Note: we do not analyze the pragma at this point. Instead we
- -- delay this analysis until the end of the declarative part in
- -- which the pragma appears. This implements the required delay
- -- in this analysis, allowing forward references. The analysis
- -- happens at the end of Analyze_Declarations.
-
- -- There should not be another contract-case or test-case with the
- -- same name associated to this subprogram.
-
- declare
- Name : constant String_Id := Get_Name_From_Case_Pragma (N);
- CTC : Node_Id;
-
- begin
- CTC := Spec_CTC_List (Contract (S));
- while Present (CTC) loop
-
- if String_Equal
- (Name, Get_Name_From_Case_Pragma (CTC))
- then
- Error_Msg_Sloc := Sloc (CTC);
-
- if From_Aspect_Specification (N) then
- Error_Pragma ("name for aspect% is already used#");
- else
- Error_Pragma ("name for pragma% is already used#");
- end if;
- end if;
-
- CTC := Next_Pragma (CTC);
- end loop;
- end;
-
- -- Chain spec CTC pragma to list for subprogram
-
- Set_Next_Pragma (N, Spec_CTC_List (Contract (S)));
- Set_Spec_CTC_List (Contract (S), N);
- end Chain_CTC;
-
- -- Start of processing for Check_Contract_Or_Test_Case
-
- begin
- if not Is_List_Member (N) then
- Pragma_Misplaced;
- end if;
-
- -- Contract-case or test-case should only appear in package spec unit
-
- if Get_Source_Unit (N) = No_Unit
- or else not Nkind_In (Sinfo.Unit (Cunit (Get_Source_Unit (N))),
- N_Package_Declaration,
- N_Generic_Package_Declaration)
- then
- Pragma_Misplaced;
- end if;
-
- -- Search prior declarations
-
- P := N;
- while Present (Prev (P)) loop
- P := Prev (P);
-
- -- If the previous node is a generic subprogram, do not go to to
- -- the original node, which is the unanalyzed tree: we need to
- -- attach the contract-case or test-case to the analyzed version
- -- at this point. They get propagated to the original tree when
- -- analyzing the corresponding body.
-
- if Nkind (P) not in N_Generic_Declaration then
- PO := Original_Node (P);
- else
- PO := P;
- end if;
-
- -- Skip past prior pragma
-
- if Nkind (PO) = N_Pragma then
- null;
-
- -- Skip stuff not coming from source
-
- elsif not Comes_From_Source (PO) then
- null;
-
- -- Only remaining possibility is subprogram declaration. First
- -- check that it is declared directly in a package declaration.
- -- This may be either the package declaration for the current unit
- -- being defined or a local package declaration.
-
- elsif not Present (Parent (Parent (PO)))
- or else not Present (Parent (Parent (Parent (PO))))
- or else not Nkind_In (Parent (Parent (PO)),
- N_Package_Declaration,
- N_Generic_Package_Declaration)
- then
- Pragma_Misplaced;
-
- else
- Chain_CTC (PO);
- return;
- end if;
- end loop;
-
- -- If we fall through, pragma was misplaced
-
- Pragma_Misplaced;
- end Check_Contract_Or_Test_Case;
-
--------------------------------------
-- Check_Valid_Configuration_Pragma --
--------------------------------------
@@ -7534,6 +7578,21 @@ package body Sem_Prag is
end if;
end Component_AlignmentP;
+ -------------------
+ -- Contract_Case --
+ -------------------
+
+ -- pragma Contract_Case
+ -- ([Name =>] Static_String_EXPRESSION
+ -- ,[Mode =>] MODE_TYPE
+ -- [, Requires => Boolean_EXPRESSION]
+ -- [, Ensures => Boolean_EXPRESSION]);
+
+ -- MODE_TYPE ::= Nominal | Robustness
+
+ when Pragma_Contract_Case =>
+ Check_Contract_Or_Test_Case;
+
----------------
-- Controlled --
----------------
@@ -13906,54 +13965,20 @@ package body Sem_Prag is
end if;
end Task_Storage;
- -------------------------------
- -- Contract_Case | Test_Case --
- -------------------------------
+ ---------------
+ -- Test_Case --
+ ---------------
- -- pragma (Contract_Case | Test_Case)
- -- ([Name =>] Static_String_EXPRESSION
- -- ,[Mode =>] MODE_TYPE
- -- [, Requires => Boolean_EXPRESSION]
- -- [, Ensures => Boolean_EXPRESSION]);
+ -- pragma Test_Case
+ -- ([Name =>] Static_String_EXPRESSION
+ -- ,[Mode =>] MODE_TYPE
+ -- [, Requires => Boolean_EXPRESSION]
+ -- [, Ensures => Boolean_EXPRESSION]);
-- MODE_TYPE ::= Nominal | Robustness
- when Pragma_Contract_Case |
- Pragma_Test_Case =>
- Contract_Or_Test_Case : declare
- begin
- GNAT_Pragma;
- Check_At_Least_N_Arguments (2);
- Check_At_Most_N_Arguments (4);
- Check_Arg_Order
- ((Name_Name, Name_Mode, Name_Requires, Name_Ensures));
-
- Check_Optional_Identifier (Arg1, Name_Name);
- Check_Arg_Is_Static_Expression (Arg1, Standard_String);
-
- -- In ASIS mode, for a pragma generated from a source aspect, also
- -- analyze the original aspect expression.
-
- if ASIS_Mode
- and then Present (Corresponding_Aspect (N))
- then
- Check_Expr_Is_Static_Expression
- (Original_Node (Get_Pragma_Arg (Arg1)), Standard_String);
- end if;
-
- Check_Optional_Identifier (Arg2, Name_Mode);
- Check_Arg_Is_One_Of (Arg2, Name_Nominal, Name_Robustness);
-
- if Arg_Count = 4 then
- Check_Identifier (Arg3, Name_Requires);
- Check_Identifier (Arg4, Name_Ensures);
-
- elsif Arg_Count = 3 then
- Check_Identifier_Is_One_Of (Arg3, Name_Requires, Name_Ensures);
- end if;
-
+ when Pragma_Test_Case =>
Check_Contract_Or_Test_Case;
- end Contract_Or_Test_Case;
--------------------------
-- Thread_Local_Storage --
@@ -14824,31 +14849,6 @@ package body Sem_Prag is
when Pragma_Exit => null;
end Analyze_Pragma;
- ------------------------------
- -- Analyze_CTC_In_Decl_Part --
- ------------------------------
-
- procedure Analyze_CTC_In_Decl_Part (N : Node_Id; S : Entity_Id) is
- begin
- -- Install formals and push subprogram spec onto scope stack so that we
- -- can see the formals from the pragma.
-
- Install_Formals (S);
- Push_Scope (S);
-
- -- Preanalyze the boolean expressions, we treat these as spec
- -- expressions (i.e. similar to a default expression).
-
- Preanalyze_CTC_Args (N,
- Get_Requires_From_Case_Pragma (N),
- Get_Ensures_From_Case_Pragma (N));
-
- -- Remove the subprogram from the scope stack now that the pre-analysis
- -- of the expressions in the contract-case or test-case is done.
-
- End_Scope;
- end Analyze_CTC_In_Decl_Part;
-
--------------------
-- Check_Disabled --
--------------------
diff --git a/gcc/ada/sem_prag.ads b/gcc/ada/sem_prag.ads
index 23a23d30648..99711546cb5 100644
--- a/gcc/ada/sem_prag.ads
+++ b/gcc/ada/sem_prag.ads
@@ -35,14 +35,6 @@ package Sem_Prag is
-- Subprograms --
-----------------
- procedure Analyze_PPC_In_Decl_Part (N : Node_Id; S : Entity_Id);
- -- Special analyze routine for precondition/postcondition pragma that
- -- appears within a declarative part where the pragma is associated
- -- with a subprogram specification. N is the pragma node, and S is the
- -- entity for the related subprogram. This procedure does a preanalysis
- -- of the expressions in the pragma as "spec expressions" (see section
- -- in Sem "Handling of Default and Per-Object Expressions...").
-
procedure Analyze_Pragma (N : Node_Id);
-- Analyze procedure for pragma reference node N
@@ -54,6 +46,14 @@ package Sem_Prag is
-- expressions in the pragma as "spec expressions" (see section in Sem
-- "Handling of Default and Per-Object Expressions...").
+ procedure Analyze_PPC_In_Decl_Part (N : Node_Id; S : Entity_Id);
+ -- Special analyze routine for precondition/postcondition pragma that
+ -- appears within a declarative part where the pragma is associated
+ -- with a subprogram specification. N is the pragma node, and S is the
+ -- entity for the related subprogram. This procedure does a preanalysis
+ -- of the expressions in the pragma as "spec expressions" (see section
+ -- in Sem "Handling of Default and Per-Object Expressions...").
+
function Check_Disabled (Nam : Name_Id) return Boolean;
-- This function is used in connection with pragmas Assertion, Check,
-- Precondition, and Postcondition, to determine if Check pragmas (or
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 93f855ff479..898222805b1 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -575,6 +575,7 @@ package Sem_Util is
function Get_Name_From_Case_Pragma (N : Node_Id) return String_Id;
-- Return the Name component of Contract_Case or Test_Case pragma N
+ -- Bad name, Case_Pragma is meaningless to me ???
function Get_Pragma_Id (N : Node_Id) return Pragma_Id;
pragma Inline (Get_Pragma_Id);
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb
index f4e70922c70..129eb35a9fb 100644
--- a/gcc/ada/sem_warn.adb
+++ b/gcc/ada/sem_warn.adb
@@ -1772,7 +1772,8 @@ package body Sem_Warn is
if Nkind (P) = N_Pragma
and then
(Pragma_Name (P) = Name_Contract_Case
- or else Pragma_Name (P) = Name_Test_Case)
+ or else
+ Pragma_Name (P) = Name_Test_Case)
and then
Nod = Get_Ensures_From_Case_Pragma (P)
then