Commit 3ccedacc by Arnaud Charlet

[multiple changes]

2014-08-04  Robert Dewar  <dewar@adacore.com>

	* sem_ch6.adb: Minor reformatting.

2014-08-04  Ed Schonberg  <schonberg@adacore.com>

	* sem_prag.adb (Analyze_Pragma, case Assert and related pragmas):
	Before normalizing these pragmas into a pragma Check, preanalyze
	the optional Message argument, (which is subsequently copied)
	so that it has the proper semantic information for ASIS use.
	* sem_case.adb: Initialize flag earlier.
	* osint.adb, osint.ads (Find_File): Add parameter Full_Name, used when
	the full source path of a configuration file is requested.
	(Read_Source_File): Use Full_Name parameter..

From-SVN: r213571
parent f3124d8f
2014-08-04 Robert Dewar <dewar@adacore.com>
* sem_ch6.adb: Minor reformatting.
2014-08-04 Ed Schonberg <schonberg@adacore.com>
* sem_prag.adb (Analyze_Pragma, case Assert and related pragmas):
Before normalizing these pragmas into a pragma Check, preanalyze
the optional Message argument, (which is subsequently copied)
so that it has the proper semantic information for ASIS use.
* sem_case.adb: Initialize flag earlier.
* osint.adb, osint.ads (Find_File): Add parameter Full_Name, used when
the full source path of a configuration file is requested.
(Read_Source_File): Use Full_Name parameter..
2014-08-04 Hristian Kirtchev <kirtchev@adacore.com> 2014-08-04 Hristian Kirtchev <kirtchev@adacore.com>
* opt.ads Alphabetize various global flags. New flag * opt.ads Alphabetize various global flags. New flag
......
...@@ -122,7 +122,8 @@ package body Osint is ...@@ -122,7 +122,8 @@ package body Osint is
(N : File_Name_Type; (N : File_Name_Type;
T : File_Type; T : File_Type;
Found : out File_Name_Type; Found : out File_Name_Type;
Attr : access File_Attributes); Attr : access File_Attributes;
Full_Name : Boolean := False);
-- A version of Find_File that also returns a cache of the file attributes -- A version of Find_File that also returns a cache of the file attributes
-- for later reuse -- for later reuse
...@@ -1154,12 +1155,13 @@ package body Osint is ...@@ -1154,12 +1155,13 @@ package body Osint is
function Find_File function Find_File
(N : File_Name_Type; (N : File_Name_Type;
T : File_Type) return File_Name_Type T : File_Type;
Full_Name : Boolean := False) return File_Name_Type
is is
Attr : aliased File_Attributes; Attr : aliased File_Attributes;
Found : File_Name_Type; Found : File_Name_Type;
begin begin
Find_File (N, T, Found, Attr'Access); Find_File (N, T, Found, Attr'Access, Full_Name);
return Found; return Found;
end Find_File; end Find_File;
...@@ -1171,7 +1173,8 @@ package body Osint is ...@@ -1171,7 +1173,8 @@ package body Osint is
(N : File_Name_Type; (N : File_Name_Type;
T : File_Type; T : File_Type;
Found : out File_Name_Type; Found : out File_Name_Type;
Attr : access File_Attributes) is Attr : access File_Attributes;
Full_Name : Boolean := False) is
begin begin
Get_Name_String (N); Get_Name_String (N);
...@@ -1193,6 +1196,20 @@ package body Osint is ...@@ -1193,6 +1196,20 @@ package body Osint is
then then
Found := N; Found := N;
Attr.all := Unknown_Attributes; Attr.all := Unknown_Attributes;
if T = Config and then Full_Name then
declare
Full_Path : constant String :=
Normalize_Pathname (Get_Name_String (N));
Full_Size : constant Natural := Full_Path'Length;
begin
Name_Buffer (1 .. Full_Size) := Full_Path;
Name_Len := Full_Size;
Found := Name_Find;
end;
end if;
return; return;
-- If we are trying to find the current main file just look in the -- If we are trying to find the current main file just look in the
...@@ -2591,7 +2608,7 @@ package body Osint is ...@@ -2591,7 +2608,7 @@ package body Osint is
-- For the call to Close -- For the call to Close
begin begin
Current_Full_Source_Name := Find_File (N, T); Current_Full_Source_Name := Find_File (N, T, Full_Name => True);
Current_Full_Source_Stamp := File_Stamp (Current_Full_Source_Name); Current_Full_Source_Stamp := File_Stamp (Current_Full_Source_Name);
if Current_Full_Source_Name = No_File then if Current_Full_Source_Name = No_File then
......
...@@ -64,7 +64,8 @@ package Osint is ...@@ -64,7 +64,8 @@ package Osint is
function Find_File function Find_File
(N : File_Name_Type; (N : File_Name_Type;
T : File_Type) return File_Name_Type; T : File_Type;
Full_Name : Boolean := False) return File_Name_Type;
-- Finds a source, library or config file depending on the value of T -- Finds a source, library or config file depending on the value of T
-- following the directory search order rules unless N is the name of the -- following the directory search order rules unless N is the name of the
-- file just read with Next_Main_File and already contains directory -- file just read with Next_Main_File and already contains directory
...@@ -76,6 +77,9 @@ package Osint is ...@@ -76,6 +77,9 @@ package Osint is
-- set and the file name ends in ".dg", in which case we look for the -- set and the file name ends in ".dg", in which case we look for the
-- generated file only in the current directory, since that is where it is -- generated file only in the current directory, since that is where it is
-- always built. -- always built.
-- In the case of configuration files, full path names are needed for some
-- ASIS queries. The flag Full_Name indicates that the name of the file
-- should be normalized to include a full path.
function Get_File_Names_Case_Sensitive return Int; function Get_File_Names_Case_Sensitive return Int;
pragma Import (C, Get_File_Names_Case_Sensitive, pragma Import (C, Get_File_Names_Case_Sensitive,
......
...@@ -735,6 +735,8 @@ package body Sem_Case is ...@@ -735,6 +735,8 @@ package body Sem_Case is
return; return;
end if; end if;
Predicate_Error := False;
-- Choice_Table must start at 0 which is an unused location used by the -- Choice_Table must start at 0 which is an unused location used by the
-- sorting algorithm. However the first valid position for a discrete -- sorting algorithm. However the first valid position for a discrete
-- choice is 1. -- choice is 1.
...@@ -762,8 +764,6 @@ package body Sem_Case is ...@@ -762,8 +764,6 @@ package body Sem_Case is
-- expression is static, independently of whether the aspect mentions -- expression is static, independently of whether the aspect mentions
-- Static explicitly. -- Static explicitly.
Predicate_Error := False;
if Has_Predicate then if Has_Predicate then
Pred := First (Static_Discrete_Predicate (Bounds_Type)); Pred := First (Static_Discrete_Predicate (Bounds_Type));
Prev_Lo := Uint_Minus_1; Prev_Lo := Uint_Minus_1;
......
...@@ -632,8 +632,8 @@ package body Sem_Ch6 is ...@@ -632,8 +632,8 @@ package body Sem_Ch6 is
and then not GNAT_Mode and then not GNAT_Mode
then then
Error_Msg_N Error_Msg_N
("(Ada 2005) cannot copy object of a limited type " & ("(Ada 2005) cannot copy object of a limited type "
"(RM-2005 6.5(5.5/2))", Expr); & "(RM-2005 6.5(5.5/2))", Expr);
if Is_Limited_View (R_Type) then if Is_Limited_View (R_Type) then
Error_Msg_N Error_Msg_N
...@@ -723,7 +723,7 @@ package body Sem_Ch6 is ...@@ -723,7 +723,7 @@ package body Sem_Ch6 is
if not Predicates_Match (R_Stm_Type, R_Type) then if not Predicates_Match (R_Stm_Type, R_Type) then
Error_Msg_Node_2 := R_Type; Error_Msg_Node_2 := R_Type;
Error_Msg_NE Error_Msg_NE
("\predicate of & does not match predicate of &", ("\predicate of& does not match predicate of&",
N, R_Stm_Type); N, R_Stm_Type);
end if; end if;
end Error_No_Match; end Error_No_Match;
...@@ -774,8 +774,8 @@ package body Sem_Ch6 is ...@@ -774,8 +774,8 @@ package body Sem_Ch6 is
elsif R_Stm_Type_Is_Anon_Access elsif R_Stm_Type_Is_Anon_Access
and then not R_Type_Is_Anon_Access and then not R_Type_Is_Anon_Access
then then
Error_Msg_N ("anonymous access not allowed for function with " & Error_Msg_N ("anonymous access not allowed for function with "
"named access result", Subtype_Ind); & "named access result", Subtype_Ind);
-- Subtype indication case: check that the return object's type is -- Subtype indication case: check that the return object's type is
-- covered by the result type, and that the subtypes statically match -- covered by the result type, and that the subtypes statically match
...@@ -942,8 +942,8 @@ package body Sem_Ch6 is ...@@ -942,8 +942,8 @@ package body Sem_Ch6 is
& "in Ada 2012??", N); & "in Ada 2012??", N);
elsif not Is_Limited_View (R_Type) then elsif not Is_Limited_View (R_Type) then
Error_Msg_N ("aliased only allowed for limited" Error_Msg_N
& " return objects", N); ("aliased only allowed for limited return objects", N);
end if; end if;
end if; end if;
end; end;
...@@ -1013,8 +1013,8 @@ package body Sem_Ch6 is ...@@ -1013,8 +1013,8 @@ package body Sem_Ch6 is
Subprogram_Access_Level (Scope_Id) Subprogram_Access_Level (Scope_Id)
then then
Error_Msg_N Error_Msg_N
("level of return expression type is deeper than " & ("level of return expression type is deeper than "
"class-wide function!", Expr); & "class-wide function!", Expr);
end if; end if;
end if; end if;
...@@ -1807,8 +1807,8 @@ package body Sem_Ch6 is ...@@ -1807,8 +1807,8 @@ package body Sem_Ch6 is
else else
Error_Msg_N Error_Msg_N
("return nested in extended return statement cannot return " & ("return nested in extended return statement cannot return "
"value (use `RETURN;`)", N); & "value (use `RETURN;`)", N);
end if; end if;
end if; end if;
...@@ -2128,7 +2128,7 @@ package body Sem_Ch6 is ...@@ -2128,7 +2128,7 @@ package body Sem_Ch6 is
and then Contains_Refined_State (Prag) and then Contains_Refined_State (Prag)
then then
Error_Msg_NE Error_Msg_NE
("body of subprogram & requires global refinement", ("body of subprogram& requires global refinement",
Body_Decl, Spec_Id); Body_Decl, Spec_Id);
end if; end if;
end if; end if;
...@@ -2151,7 +2151,7 @@ package body Sem_Ch6 is ...@@ -2151,7 +2151,7 @@ package body Sem_Ch6 is
and then Contains_Refined_State (Prag) and then Contains_Refined_State (Prag)
then then
Error_Msg_NE Error_Msg_NE
("body of subprogram & requires dependance refinement", ("body of subprogram& requires dependance refinement",
Body_Decl, Spec_Id); Body_Decl, Spec_Id);
end if; end if;
end if; end if;
...@@ -2952,7 +2952,7 @@ package body Sem_Ch6 is ...@@ -2952,7 +2952,7 @@ package body Sem_Ch6 is
and then Operator_Matches_Spec (Spec_Id, Spec_Id) and then Operator_Matches_Spec (Spec_Id, Spec_Id)
then then
Error_Msg_NE Error_Msg_NE
("subprogram & overrides predefined operator ", ("subprogram& overrides predefined operator ",
Body_Spec, Spec_Id); Body_Spec, Spec_Id);
-- Overriding indicators aren't allowed for protected subprogram -- Overriding indicators aren't allowed for protected subprogram
...@@ -2963,18 +2963,16 @@ package body Sem_Ch6 is ...@@ -2963,18 +2963,16 @@ package body Sem_Ch6 is
Error_Msg_Warn := Error_To_Warning; Error_Msg_Warn := Error_To_Warning;
Error_Msg_N Error_Msg_N
("<<overriding indicator not allowed " & ("<<overriding indicator not allowed "
"for protected subprogram body", & "for protected subprogram body", Body_Spec);
Body_Spec);
-- If this is not a primitive operation, then the overriding -- If this is not a primitive operation, then the overriding
-- indicator is altogether illegal. -- indicator is altogether illegal.
elsif not Is_Primitive (Spec_Id) then elsif not Is_Primitive (Spec_Id) then
Error_Msg_N Error_Msg_N
("overriding indicator only allowed " & ("overriding indicator only allowed "
"if subprogram is primitive", & "if subprogram is primitive", Body_Spec);
Body_Spec);
end if; end if;
-- If checking the style rule and the operation overrides, then -- If checking the style rule and the operation overrides, then
...@@ -3764,7 +3762,7 @@ package body Sem_Ch6 is ...@@ -3764,7 +3762,7 @@ package body Sem_Ch6 is
else else
Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id)); Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id));
Error_Msg_N ("incorrect application of SPARK_Mode#", N); Error_Msg_N ("incorrect application of SPARK_Mode #", N);
Error_Msg_Sloc := Sloc (Spec_Id); Error_Msg_Sloc := Sloc (Spec_Id);
Error_Msg_NE Error_Msg_NE
("\no value was set for SPARK_Mode on & #", N, Spec_Id); ("\no value was set for SPARK_Mode on & #", N, Spec_Id);
...@@ -4746,7 +4744,7 @@ package body Sem_Ch6 is ...@@ -4746,7 +4744,7 @@ package body Sem_Ch6 is
-- this before checking that the types of the formals match. -- this before checking that the types of the formals match.
if Chars (Old_Formal) /= Chars (New_Formal) then if Chars (Old_Formal) /= Chars (New_Formal) then
Conformance_Error ("\name & does not match!", New_Formal); Conformance_Error ("\name& does not match!", New_Formal);
-- Set error posted flag on new formal as well to stop -- Set error posted flag on new formal as well to stop
-- junk cascaded messages in some cases. -- junk cascaded messages in some cases.
...@@ -4769,7 +4767,7 @@ package body Sem_Ch6 is ...@@ -4769,7 +4767,7 @@ package body Sem_Ch6 is
Comes_From_Source (New_Formal) Comes_From_Source (New_Formal)
then then
Conformance_Error Conformance_Error
("\null exclusion for & does not match", New_Formal); ("\null exclusion for& does not match", New_Formal);
-- Mark error posted on the new formal to avoid duplicated -- Mark error posted on the new formal to avoid duplicated
-- complaint about types not matching. -- complaint about types not matching.
...@@ -4905,8 +4903,7 @@ package body Sem_Ch6 is ...@@ -4905,8 +4903,7 @@ package body Sem_Ch6 is
declare declare
T : constant Entity_Id := Find_Dispatching_Type (New_Id); T : constant Entity_Id := Find_Dispatching_Type (New_Id);
begin begin
if Is_Protected_Type if Is_Protected_Type (Corresponding_Concurrent_Type (T))
(Corresponding_Concurrent_Type (T))
then then
Error_Msg_PT (T, New_Id); Error_Msg_PT (T, New_Id);
else else
...@@ -4979,7 +4976,7 @@ package body Sem_Ch6 is ...@@ -4979,7 +4976,7 @@ package body Sem_Ch6 is
if Is_Controlling_Formal (New_Formal) then if Is_Controlling_Formal (New_Formal) then
Error_Msg_Node_2 := Scope (New_Formal); Error_Msg_Node_2 := Scope (New_Formal);
Conformance_Error Conformance_Error
("\controlling formal& of& excludes null, " ("\controlling formal & of & excludes null, "
& "declaration must exclude null as well", & "declaration must exclude null as well",
New_Formal); New_Formal);
...@@ -5175,23 +5172,21 @@ package body Sem_Ch6 is ...@@ -5175,23 +5172,21 @@ package body Sem_Ch6 is
Error_Msg_N ("\\primitive % defined #", Typ); Error_Msg_N ("\\primitive % defined #", Typ);
else else
Error_Msg_N Error_Msg_N
("\\overriding operation % with " & ("\\overriding operation % with "
"convention % defined #", Typ); & "convention % defined #", Typ);
end if; end if;
else pragma Assert (Present (Alias (Op))); else pragma Assert (Present (Alias (Op)));
Error_Msg_Sloc := Sloc (Alias (Op)); Error_Msg_Sloc := Sloc (Alias (Op));
Error_Msg_N Error_Msg_N ("\\inherited operation % with "
("\\inherited operation % with " & & "convention % defined #", Typ);
"convention % defined #", Typ);
end if; end if;
Error_Msg_Name_1 := Chars (Op); Error_Msg_Name_1 := Chars (Op);
Error_Msg_Name_2 := Get_Convention_Name (Iface_Conv); Error_Msg_Name_2 := Get_Convention_Name (Iface_Conv);
Error_Msg_Sloc := Sloc (Iface_Prim); Error_Msg_Sloc := Sloc (Iface_Prim);
Error_Msg_N Error_Msg_N ("\\overridden operation % with "
("\\overridden operation % with " & & "convention % defined #", Typ);
"convention % defined #", Typ);
-- Avoid cascading errors -- Avoid cascading errors
...@@ -5722,8 +5717,7 @@ package body Sem_Ch6 is ...@@ -5722,8 +5717,7 @@ package body Sem_Ch6 is
if not Is_Primitive if not Is_Primitive
and then Ekind (Scope (Subp)) /= E_Protected_Type and then Ekind (Scope (Subp)) /= E_Protected_Type
then then
Error_Msg_N Error_Msg_N ("overriding indicator only allowed "
("overriding indicator only allowed "
& "if subprogram is primitive", Subp); & "if subprogram is primitive", Subp);
elsif Can_Override_Operator (Subp) then elsif Can_Override_Operator (Subp) then
...@@ -7085,7 +7079,7 @@ package body Sem_Ch6 is ...@@ -7085,7 +7079,7 @@ package body Sem_Ch6 is
then then
if Scope (E) /= Standard_Standard then if Scope (E) /= Standard_Standard then
Error_Msg_Sloc := Sloc (E); Error_Msg_Sloc := Sloc (E);
Error_Msg_N ("declaration of & hides one#?h?", S); Error_Msg_N ("declaration of & hides one #?h?", S);
elsif Nkind (S) = N_Defining_Operator_Symbol elsif Nkind (S) = N_Defining_Operator_Symbol
and then and then
...@@ -7159,7 +7153,7 @@ package body Sem_Ch6 is ...@@ -7159,7 +7153,7 @@ package body Sem_Ch6 is
else else
if Ada_Version >= Ada_2012 then if Ada_Version >= Ada_2012 then
Error_Msg_NE Error_Msg_NE
("equality operator must be declared before type& is " ("equality operator must be declared before type & is "
& "frozen (RM 4.5.2 (9.8)) (Ada 2012)<<", Eq_Op, Typ); & "frozen (RM 4.5.2 (9.8)) (Ada 2012)<<", Eq_Op, Typ);
-- In Ada 2012 mode with error turned to warning, output one -- In Ada 2012 mode with error turned to warning, output one
...@@ -8395,8 +8389,8 @@ package body Sem_Ch6 is ...@@ -8395,8 +8389,8 @@ package body Sem_Ch6 is
then then
Error_Msg_Node_2 := F_Typ; Error_Msg_Node_2 := F_Typ;
Error_Msg_NE Error_Msg_NE
("private operation& in generic unit does not override " & ("private operation& in generic unit does not override "
"any primitive operation of& (RM 12.3 (18))??", & "any primitive operation of& (RM 12.3 (18))??",
New_E, New_E); New_E, New_E);
end if; end if;
...@@ -8429,13 +8423,11 @@ package body Sem_Ch6 is ...@@ -8429,13 +8423,11 @@ package body Sem_Ch6 is
if Class_Present (P) and then not Split_PPC (P) then if Class_Present (P) and then not Split_PPC (P) then
if Pragma_Name (P) = Name_Precondition then if Pragma_Name (P) = Name_Precondition then
Error_Msg_N Error_Msg_N ("info: & inherits `Pre''Class` aspect "
("info: & inherits `Pre''Class` aspect from #?L?", & "from #?L?", E);
E);
else else
Error_Msg_N Error_Msg_N ("info: & inherits `Post''Class` aspect "
("info: & inherits `Post''Class` aspect from #?L?", & "from #?L?", E);
E);
end if; end if;
end if; end if;
...@@ -8663,17 +8655,14 @@ package body Sem_Ch6 is ...@@ -8663,17 +8655,14 @@ package body Sem_Ch6 is
and then (not Is_Overriding and then (not Is_Overriding
or else not Is_Abstract_Subprogram (E)) or else not Is_Abstract_Subprogram (E))
then then
Error_Msg_N Error_Msg_N ("abstract subprograms must be visible "
("abstract subprograms must be visible "
& "(RM 3.9.3(10))!", S); & "(RM 3.9.3(10))!", S);
elsif Ekind (S) = E_Function and then not Is_Overriding then elsif Ekind (S) = E_Function and then not Is_Overriding then
if Is_Tagged_Type (T) and then T = Base_Type (Etype (S)) then if Is_Tagged_Type (T) and then T = Base_Type (Etype (S)) then
Error_Msg_N Error_Msg_N ("private function with tagged result must"
("private function with tagged result must"
& " override visible-part function", S); & " override visible-part function", S);
Error_Msg_N Error_Msg_N ("\move subprogram to the visible part"
("\move subprogram to the visible part"
& " (RM 3.9.3(10))", S); & " (RM 3.9.3(10))", S);
-- AI05-0073: extend this test to the case of a function -- AI05-0073: extend this test to the case of a function
......
...@@ -11010,6 +11010,11 @@ package body Sem_Prag is ...@@ -11010,6 +11010,11 @@ package body Sem_Prag is
if Arg_Count > 1 then if Arg_Count > 1 then
Check_Optional_Identifier (Arg2, Name_Message); Check_Optional_Identifier (Arg2, Name_Message);
-- Provide semantic annnotations for optional argument, for
-- ASIS use, before rewriting.
Preanalyze_And_Resolve (Expression (Arg2), Standard_String);
Append_To (Newa, New_Copy_Tree (Arg2)); Append_To (Newa, New_Copy_Tree (Arg2));
end if; end if;
...@@ -19319,7 +19324,6 @@ package body Sem_Prag is ...@@ -19319,7 +19324,6 @@ package body Sem_Prag is
else else
Spec_Id := Defining_Entity (Unit (Context)); Spec_Id := Defining_Entity (Unit (Context));
Inst_Id := Related_Instance (Spec_Id);
Check_Library_Level_Entity (Spec_Id); Check_Library_Level_Entity (Spec_Id);
Check_Pragma_Conformance Check_Pragma_Conformance
(Context_Pragma => SPARK_Mode_Pragma, (Context_Pragma => SPARK_Mode_Pragma,
...@@ -19329,7 +19333,10 @@ package body Sem_Prag is ...@@ -19329,7 +19333,10 @@ package body Sem_Prag is
Set_SPARK_Pragma (Spec_Id, N); Set_SPARK_Pragma (Spec_Id, N);
Set_SPARK_Pragma_Inherited (Spec_Id, False); Set_SPARK_Pragma_Inherited (Spec_Id, False);
if Present (Inst_Id) then if Ekind (Spec_Id) = E_Package
and then Present (Related_Instance (Spec_Id))
then
Inst_Id := Related_Instance (Spec_Id);
Set_SPARK_Pragma (Inst_Id, N); Set_SPARK_Pragma (Inst_Id, N);
Set_SPARK_Pragma_Inherited (Inst_Id, False); Set_SPARK_Pragma_Inherited (Inst_Id, False);
end if; end if;
......
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