+2014-01-23 Robert Dewar <dewar@adacore.com>
+
+ * gnatlink.adb (Gnatlink): Fix problem of generating bad name
+ msg on VMS.
+
+2014-01-23 Bob Duff <duff@adacore.com>
+
+ * g-dynhta.ads: Minor comment fix.
+
+2014-01-23 Yannick Moy <moy@adacore.com>
+
+ * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Inherit SPARK_Mode
+ from spec on body only when not already inherited on spec. Set
+ SPARK_Mode from context on body without previous spec. *
+ * sem_prag.adb (Analyze_Pragma): Check placement of pragma on
+ library-level entities. Correct retrieval of entity from
+ declaration, for cases where the declaration is not a unit.
+ * sem_ch12.adb (Instantiate_Object): Avoid
+ calling Is_Volatile_Object on an empty node.
+
2014-01-23 Robert Dewar <dewar@adacore.com>
* gnatlink.adb (Gnatlink): Check for suspicious executable file
-- Set SPARK_Mode from spec if spec had a SPARK_Mode pragma
- if Present (SPARK_Pragma (Spec_Id)) then
+ if Present (SPARK_Pragma (Spec_Id))
+ and then not SPARK_Pragma_Inherited (Spec_Id)
+ then
SPARK_Mode_Pragma := SPARK_Pragma (Spec_Id);
SPARK_Mode := Get_SPARK_Mode_From_Pragma (SPARK_Mode_Pragma);
Set_SPARK_Pragma (Body_Id, SPARK_Pragma (Spec_Id));
Generate_Reference
(Body_Id, Body_Id, 'b', Set_Ref => False, Force => True);
Install_Formals (Body_Id);
+
+ -- Set SPARK_Mode from context
+
+ Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma);
+ Set_SPARK_Pragma_Inherited (Body_Id, True);
+
Push_Scope (Body_Id);
end if;
-- anything. But if the old mode is OFF, then the only allowed
-- new mode is also OFF.
+ procedure Check_Library_Level_Entity (E : Entity_Id);
+ -- Verify that pragma is applied to library-level entity E
+
function Get_SPARK_Mode_Name (Id : SPARK_Mode_Type) return Name_Id;
-- Convert a value of type SPARK_Mode_Type to corresponding name
end if;
end Check_Pragma_Conformance;
+ --------------------------------
+ -- Check_Library_Level_Entity --
+ --------------------------------
+
+ procedure Check_Library_Level_Entity (E : Entity_Id) is
+ MsgF : String := "incorrect placement of pragma%";
+
+ begin
+ if not Is_Library_Level_Entity (E) then
+ Error_Msg_Name_1 := Pname;
+ Fix_Error (MsgF);
+ Error_Msg_N (MsgF, N);
+
+ if Ekind_In (E, E_Generic_Package,
+ E_Package,
+ E_Package_Body)
+ then
+ Error_Msg_NE
+ ("\& is not a library-level package", N, E);
+ else
+ Error_Msg_NE
+ ("\& is not a library-level subprogram", N, E);
+ end if;
+
+ raise Pragma_Exit;
+ end if;
+ end Check_Library_Level_Entity;
+
-------------------------
-- Get_SPARK_Mode_Name --
-------------------------
elsif Nkind_In (Stmt, N_Generic_Package_Declaration,
N_Package_Declaration)
then
- Spec_Id := Defining_Unit_Name (Specification (Stmt));
+ Spec_Id := Defining_Entity (Stmt);
+ Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance (SPARK_Pragma (Spec_Id));
Set_SPARK_Pragma (Spec_Id, N);
elsif Nkind_In (Stmt, N_Generic_Subprogram_Declaration,
N_Subprogram_Declaration)
then
- Spec_Id := Defining_Unit_Name (Specification (Stmt));
+ Spec_Id := Defining_Entity (Stmt);
+ Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance (SPARK_Pragma (Spec_Id));
Set_SPARK_Pragma (Spec_Id, N);
-- pragma SPARK_Mode;
if Nkind (Context) = N_Package_Specification then
- Spec_Id := Defining_Unit_Name (Context);
+ Spec_Id := Defining_Entity (Context);
-- Pragma applies to private part
if List_Containing (N) = Private_Declarations (Context) then
+ Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance (SPARK_Aux_Pragma (Spec_Id));
SPARK_Mode_Pragma := N;
SPARK_Mode := Mode_Id;
-- Pragma applies to public part
else
+ Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance (SPARK_Pragma (Spec_Id));
SPARK_Mode_Pragma := N;
SPARK_Mode := Mode_Id;
elsif Nkind_In (Context, N_Function_Specification,
N_Procedure_Specification)
then
- Spec_Id := Defining_Unit_Name (Context);
+ Spec_Id := Defining_Entity (Context);
+ Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance (SPARK_Pragma (Spec_Id));
Set_SPARK_Pragma (Spec_Id, N);
elsif Nkind (Context) = N_Package_Body then
Spec_Id := Corresponding_Spec (Context);
Body_Id := Defining_Entity (Context);
+ Check_Library_Level_Entity (Body_Id);
Check_Pragma_Conformance (SPARK_Pragma (Body_Id));
SPARK_Mode_Pragma := N;
SPARK_Mode := Mode_Id;
Spec_Id := Corresponding_Spec (Context);
Context := Specification (Context);
Body_Id := Defining_Entity (Context);
+ Check_Library_Level_Entity (Body_Id);
Check_Pragma_Conformance (SPARK_Pragma (Body_Id));
SPARK_Mode_Pragma := N;
SPARK_Mode := Mode_Id;
then
Context := Parent (Context);
Spec_Id := Corresponding_Spec (Context);
- Body_Id := Defining_Unit_Name (Context);
+ Body_Id := Defining_Entity (Context);
+ Check_Library_Level_Entity (Body_Id);
Check_Pragma_Conformance (SPARK_Aux_Pragma (Body_Id));
SPARK_Mode_Pragma := N;
SPARK_Mode := Mode_Id;