GCC with patches for OS216
修订版 | 0e77949e878dd109ee7daffcda12faa1a8000d29 (tree) |
---|---|
时间 | 2016-07-07 22:05:08 |
作者 | Arnaud Charlet <charlet@gcc....> |
Commiter | Arnaud Charlet |
[multiple changes]
2016-07-07 Ed Schonberg <schonberg@adacore.com>
* sem_prag.ads, sem_prag.adb (Build_Classwide_Expression): Include
overridden operation as parameter, in order to map formals of
the overridden and overring operation properly prior to rewriting
the inherited condition.
* freeze.adb (Check_Inherited_Cnonditions): Change call to
Build_Class_Wide_Expression accordingly. In Spark_Mode, add
call to analyze the contract of the parent operation, prior to
mapping formals between operations.
2016-07-07 Arnaud Charlet <charlet@adacore.com>
* adabkend.adb (Scan_Back_End_Switches): Ignore -o/-G switches
as done in back_end.adb.
(Scan_Compiler_Args): Remove special case for CodePeer/SPARK, no longer
needed, and prevents proper handling of multi-unit sources.
2016-07-07 Thomas Quinot <quinot@adacore.com>
* g-sechas.adb, g-sechas.ads (GNAT.Secure_Hashes.H): Add Hash_Stream
type with Write primitive calling Update on the underlying context
(and dummy Read primitive raising P_E).
2016-07-07 Thomas Quinot <quinot@adacore.com>
* sem_ch13.adb: Minor reformatting.
From-SVN: r238111
@@ -1,3 +1,31 @@ | ||
1 | +2016-07-07 Ed Schonberg <schonberg@adacore.com> | |
2 | + | |
3 | + * sem_prag.ads, sem_prag.adb (Build_Classwide_Expression): Include | |
4 | + overridden operation as parameter, in order to map formals of | |
5 | + the overridden and overring operation properly prior to rewriting | |
6 | + the inherited condition. | |
7 | + * freeze.adb (Check_Inherited_Cnonditions): Change call to | |
8 | + Build_Class_Wide_Expression accordingly. In Spark_Mode, add | |
9 | + call to analyze the contract of the parent operation, prior to | |
10 | + mapping formals between operations. | |
11 | + | |
12 | +2016-07-07 Arnaud Charlet <charlet@adacore.com> | |
13 | + | |
14 | + * adabkend.adb (Scan_Back_End_Switches): Ignore -o/-G switches | |
15 | + as done in back_end.adb. | |
16 | + (Scan_Compiler_Args): Remove special case for CodePeer/SPARK, no longer | |
17 | + needed, and prevents proper handling of multi-unit sources. | |
18 | + | |
19 | +2016-07-07 Thomas Quinot <quinot@adacore.com> | |
20 | + | |
21 | + * g-sechas.adb, g-sechas.ads (GNAT.Secure_Hashes.H): Add Hash_Stream | |
22 | + type with Write primitive calling Update on the underlying context | |
23 | + (and dummy Read primitive raising P_E). | |
24 | + | |
25 | +2016-07-07 Thomas Quinot <quinot@adacore.com> | |
26 | + | |
27 | + * sem_ch13.adb: Minor reformatting. | |
28 | + | |
1 | 29 | 2016-07-07 Thomas Quinot <quinot@adacore.com> |
2 | 30 | |
3 | 31 | * g-socket.ads: Document performance consideration for stream |
@@ -98,31 +98,15 @@ package body Adabkend is | ||
98 | 98 | -- affect code generation or falling through if it does, so the |
99 | 99 | -- switch will get stored. |
100 | 100 | |
101 | - if Is_Internal_GCC_Switch (Switch_Chars) then | |
101 | + -- Skip -o, -G or internal GCC switches together with their argument. | |
102 | + | |
103 | + if Switch_Chars (First .. Last) = "o" | |
104 | + or else Switch_Chars (First .. Last) = "G" | |
105 | + or else Is_Internal_GCC_Switch (Switch_Chars) | |
106 | + then | |
102 | 107 | Next_Arg := Next_Arg + 1; |
103 | 108 | return; -- ignore this switch |
104 | 109 | |
105 | - -- Record that an object file name has been specified. The actual | |
106 | - -- file name argument is picked up and saved below by the main body | |
107 | - -- of Scan_Compiler_Arguments. | |
108 | - | |
109 | - elsif Switch_Chars (First .. Last) = "o" then | |
110 | - if First = Last then | |
111 | - if Opt.Output_File_Name_Present then | |
112 | - | |
113 | - -- Ignore extra -o when -gnatO has already been specified | |
114 | - | |
115 | - Next_Arg := Next_Arg + 1; | |
116 | - | |
117 | - else | |
118 | - Opt.Output_File_Name_Present := True; | |
119 | - end if; | |
120 | - | |
121 | - return; | |
122 | - else | |
123 | - Fail ("invalid switch: " & Switch_Chars); | |
124 | - end if; | |
125 | - | |
126 | 110 | -- Set optimization indicators appropriately. In gcc-based GNAT this |
127 | 111 | -- is picked up from imported variables set by the gcc driver, but |
128 | 112 | -- for compilers with non-gcc back ends we do it here to allow use |
@@ -244,16 +228,6 @@ package body Adabkend is | ||
244 | 228 | then |
245 | 229 | if Is_Switch (Argv) then |
246 | 230 | Fail ("Object file name missing after -gnatO"); |
247 | - | |
248 | - -- In GNATprove_Mode, such an object file is never written, and | |
249 | - -- the call to Set_Output_Object_File_Name may fail (e.g. when | |
250 | - -- the object file name does not have the expected suffix). | |
251 | - -- So we skip that call when GNATprove_Mode is set. Same for | |
252 | - -- CodePeer_Mode. | |
253 | - | |
254 | - elsif GNATprove_Mode or CodePeer_Mode then | |
255 | - Output_File_Name_Seen := True; | |
256 | - | |
257 | 231 | else |
258 | 232 | Set_Output_Object_File_Name (Argv); |
259 | 233 | Output_File_Name_Seen := True; |
@@ -23,51 +23,52 @@ | ||
23 | 23 | -- -- |
24 | 24 | ------------------------------------------------------------------------------ |
25 | 25 | |
26 | -with Aspects; use Aspects; | |
27 | -with Atree; use Atree; | |
28 | -with Checks; use Checks; | |
29 | -with Debug; use Debug; | |
30 | -with Einfo; use Einfo; | |
31 | -with Elists; use Elists; | |
32 | -with Errout; use Errout; | |
33 | -with Exp_Ch3; use Exp_Ch3; | |
34 | -with Exp_Ch7; use Exp_Ch7; | |
35 | -with Exp_Disp; use Exp_Disp; | |
36 | -with Exp_Pakd; use Exp_Pakd; | |
37 | -with Exp_Util; use Exp_Util; | |
38 | -with Exp_Tss; use Exp_Tss; | |
39 | -with Fname; use Fname; | |
40 | -with Ghost; use Ghost; | |
41 | -with Layout; use Layout; | |
42 | -with Lib; use Lib; | |
43 | -with Namet; use Namet; | |
44 | -with Nlists; use Nlists; | |
45 | -with Nmake; use Nmake; | |
46 | -with Opt; use Opt; | |
47 | -with Restrict; use Restrict; | |
48 | -with Rident; use Rident; | |
49 | -with Rtsfind; use Rtsfind; | |
50 | -with Sem; use Sem; | |
51 | -with Sem_Aux; use Sem_Aux; | |
52 | -with Sem_Cat; use Sem_Cat; | |
53 | -with Sem_Ch6; use Sem_Ch6; | |
54 | -with Sem_Ch7; use Sem_Ch7; | |
55 | -with Sem_Ch8; use Sem_Ch8; | |
56 | -with Sem_Ch13; use Sem_Ch13; | |
57 | -with Sem_Eval; use Sem_Eval; | |
58 | -with Sem_Mech; use Sem_Mech; | |
59 | -with Sem_Prag; use Sem_Prag; | |
60 | -with Sem_Res; use Sem_Res; | |
61 | -with Sem_Util; use Sem_Util; | |
62 | -with Sinfo; use Sinfo; | |
63 | -with Snames; use Snames; | |
64 | -with Stand; use Stand; | |
65 | -with Targparm; use Targparm; | |
66 | -with Tbuild; use Tbuild; | |
67 | -with Ttypes; use Ttypes; | |
68 | -with Uintp; use Uintp; | |
69 | -with Urealp; use Urealp; | |
70 | -with Warnsw; use Warnsw; | |
26 | +with Aspects; use Aspects; | |
27 | +with Atree; use Atree; | |
28 | +with Checks; use Checks; | |
29 | +with Contracts; use Contracts; | |
30 | +with Debug; use Debug; | |
31 | +with Einfo; use Einfo; | |
32 | +with Elists; use Elists; | |
33 | +with Errout; use Errout; | |
34 | +with Exp_Ch3; use Exp_Ch3; | |
35 | +with Exp_Ch7; use Exp_Ch7; | |
36 | +with Exp_Disp; use Exp_Disp; | |
37 | +with Exp_Pakd; use Exp_Pakd; | |
38 | +with Exp_Util; use Exp_Util; | |
39 | +with Exp_Tss; use Exp_Tss; | |
40 | +with Fname; use Fname; | |
41 | +with Ghost; use Ghost; | |
42 | +with Layout; use Layout; | |
43 | +with Lib; use Lib; | |
44 | +with Namet; use Namet; | |
45 | +with Nlists; use Nlists; | |
46 | +with Nmake; use Nmake; | |
47 | +with Opt; use Opt; | |
48 | +with Restrict; use Restrict; | |
49 | +with Rident; use Rident; | |
50 | +with Rtsfind; use Rtsfind; | |
51 | +with Sem; use Sem; | |
52 | +with Sem_Aux; use Sem_Aux; | |
53 | +with Sem_Cat; use Sem_Cat; | |
54 | +with Sem_Ch6; use Sem_Ch6; | |
55 | +with Sem_Ch7; use Sem_Ch7; | |
56 | +with Sem_Ch8; use Sem_Ch8; | |
57 | +with Sem_Ch13; use Sem_Ch13; | |
58 | +with Sem_Eval; use Sem_Eval; | |
59 | +with Sem_Mech; use Sem_Mech; | |
60 | +with Sem_Prag; use Sem_Prag; | |
61 | +with Sem_Res; use Sem_Res; | |
62 | +with Sem_Util; use Sem_Util; | |
63 | +with Sinfo; use Sinfo; | |
64 | +with Snames; use Snames; | |
65 | +with Stand; use Stand; | |
66 | +with Targparm; use Targparm; | |
67 | +with Tbuild; use Tbuild; | |
68 | +with Ttypes; use Ttypes; | |
69 | +with Uintp; use Uintp; | |
70 | +with Urealp; use Urealp; | |
71 | +with Warnsw; use Warnsw; | |
71 | 72 | |
72 | 73 | package body Freeze is |
73 | 74 |
@@ -1417,6 +1418,16 @@ package body Freeze is | ||
1417 | 1418 | -- overriding operations. |
1418 | 1419 | |
1419 | 1420 | if SPARK_Mode = On then |
1421 | + | |
1422 | + -- Analyze the contract items of the parent operation, before | |
1423 | + -- they are rewritten when inherited. | |
1424 | + | |
1425 | + Analyze_Entry_Or_Subprogram_Contract | |
1426 | + (Overridden_Operation (Prim)); | |
1427 | + | |
1428 | + -- Now verify the legality of inherited contracts for LSP | |
1429 | + -- conformance. | |
1430 | + | |
1420 | 1431 | Collect_Inherited_Class_Wide_Conditions (Prim); |
1421 | 1432 | end if; |
1422 | 1433 | end if; |
@@ -1440,15 +1451,15 @@ package body Freeze is | ||
1440 | 1451 | A_Pre := Find_Aspect (Par_Prim, Aspect_Pre); |
1441 | 1452 | |
1442 | 1453 | if Present (A_Pre) and then Class_Present (A_Pre) then |
1443 | - Build_Classwide_Expression (Expression (A_Pre), Prim, | |
1444 | - Adjust_Sloc => False); | |
1454 | + Build_Classwide_Expression | |
1455 | + (Expression (A_Pre), Prim, Par_Prim, Adjust_Sloc => False); | |
1445 | 1456 | end if; |
1446 | 1457 | |
1447 | 1458 | A_Post := Find_Aspect (Par_Prim, Aspect_Post); |
1448 | 1459 | |
1449 | 1460 | if Present (A_Post) and then Class_Present (A_Post) then |
1450 | - Build_Classwide_Expression (Expression (A_Post), Prim, | |
1451 | - Adjust_Sloc => False); | |
1461 | + Build_Classwide_Expression | |
1462 | + (Expression (A_Post), Prim, Par_Prim, Adjust_Sloc => False); | |
1452 | 1463 | end if; |
1453 | 1464 | end if; |
1454 | 1465 |
@@ -6,7 +6,7 @@ | ||
6 | 6 | -- -- |
7 | 7 | -- B o d y -- |
8 | 8 | -- -- |
9 | --- Copyright (C) 2009-2014, Free Software Foundation, Inc. -- | |
9 | +-- Copyright (C) 2009-2016, Free Software Foundation, Inc. -- | |
10 | 10 | -- -- |
11 | 11 | -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 | 12 | -- terms of the GNU General Public License as published by the Free Soft- -- |
@@ -341,6 +341,20 @@ package body GNAT.Secure_Hashes is | ||
341 | 341 | end return; |
342 | 342 | end HMAC_Initial_Context; |
343 | 343 | |
344 | + ---------- | |
345 | + -- Read -- | |
346 | + ---------- | |
347 | + | |
348 | + procedure Read | |
349 | + (Stream : in out Hash_Stream; | |
350 | + Item : out Stream_Element_Array; | |
351 | + Last : out Stream_Element_Offset) | |
352 | + is | |
353 | + pragma Unreferenced (Stream, Item, Last); | |
354 | + begin | |
355 | + raise Program_Error with "Hash_Stream is write-only"; | |
356 | + end Read; | |
357 | + | |
344 | 358 | ------------ |
345 | 359 | -- Update -- |
346 | 360 | ------------ |
@@ -364,7 +378,6 @@ package body GNAT.Secure_Hashes is | ||
364 | 378 | C.M_State.Last := 0; |
365 | 379 | end if; |
366 | 380 | end loop; |
367 | - | |
368 | 381 | end Update; |
369 | 382 | |
370 | 383 | ------------ |
@@ -422,6 +435,18 @@ package body GNAT.Secure_Hashes is | ||
422 | 435 | return Digest (C); |
423 | 436 | end Wide_Digest; |
424 | 437 | |
438 | + ----------- | |
439 | + -- Write -- | |
440 | + ----------- | |
441 | + | |
442 | + procedure Write | |
443 | + (Stream : in out Hash_Stream; | |
444 | + Item : Stream_Element_Array) | |
445 | + is | |
446 | + begin | |
447 | + Update (Stream.C.all, Item); | |
448 | + end Write; | |
449 | + | |
425 | 450 | end H; |
426 | 451 | |
427 | 452 | ------------------------- |
@@ -6,7 +6,7 @@ | ||
6 | 6 | -- -- |
7 | 7 | -- S p e c -- |
8 | 8 | -- -- |
9 | --- Copyright (C) 2009-2014, Free Software Foundation, Inc. -- | |
9 | +-- Copyright (C) 2009-2016, Free Software Foundation, Inc. -- | |
10 | 10 | -- -- |
11 | 11 | -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 | 12 | -- terms of the GNU General Public License as published by the Free Soft- -- |
@@ -191,6 +191,12 @@ package GNAT.Secure_Hashes is | ||
191 | 191 | -- Wide_Update) on a default initialized Context, followed by Digest |
192 | 192 | -- on the resulting Context. |
193 | 193 | |
194 | + type Hash_Stream (C : access Context) is | |
195 | + new Root_Stream_Type with private; | |
196 | + -- Stream wrapper converting Write calls to Update calls on C. | |
197 | + -- Arbitrary data structures can thus be conveniently hashed using | |
198 | + -- their stream attributes. | |
199 | + | |
194 | 200 | private |
195 | 201 | |
196 | 202 | Block_Length : constant Natural := Block_Words * Word_Length; |
@@ -215,6 +221,20 @@ package GNAT.Secure_Hashes is | ||
215 | 221 | Initial_Context : constant Context (KL => 0) := (others => <>); |
216 | 222 | -- Initial values are provided by default initialization of Context |
217 | 223 | |
224 | + type Hash_Stream (C : access Context) is | |
225 | + new Root_Stream_Type with null record; | |
226 | + | |
227 | + procedure Read | |
228 | + (Stream : in out Hash_Stream; | |
229 | + Item : out Stream_Element_Array; | |
230 | + Last : out Stream_Element_Offset); | |
231 | + -- Raise Program_Error: hash streams are write-only | |
232 | + | |
233 | + procedure Write | |
234 | + (Stream : in out Hash_Stream; | |
235 | + Item : Stream_Element_Array); | |
236 | + -- Call Update | |
237 | + | |
218 | 238 | end H; |
219 | 239 | |
220 | 240 | end GNAT.Secure_Hashes; |
@@ -3823,8 +3823,8 @@ package body Sem_Ch13 is | ||
3823 | 3823 | U_Ent : Entity_Id; |
3824 | 3824 | -- The underlying entity to which the attribute applies. Generally this |
3825 | 3825 | -- is the Underlying_Type of Ent, except in the case where the clause |
3826 | - -- applies to full view of incomplete type or private type in which case | |
3827 | - -- U_Ent is just a copy of Ent. | |
3826 | + -- applies to the full view of an incomplete or private type, in which | |
3827 | + -- case U_Ent is just a copy of Ent. | |
3828 | 3828 | |
3829 | 3829 | FOnly : Boolean := False; |
3830 | 3830 | -- Reset to True for subtype specific attribute (Alignment, Size) |
@@ -26396,8 +26396,12 @@ package body Sem_Prag is | ||
26396 | 26396 | procedure Build_Classwide_Expression |
26397 | 26397 | (Prag : Node_Id; |
26398 | 26398 | Subp : Entity_Id; |
26399 | + Par_Subp : Entity_Id; | |
26399 | 26400 | Adjust_Sloc : Boolean) |
26400 | 26401 | is |
26402 | + Par_Formal : Entity_Id; | |
26403 | + Subp_Formal : Entity_Id; | |
26404 | + | |
26401 | 26405 | function Replace_Entity (N : Node_Id) return Traverse_Result; |
26402 | 26406 | -- Replace reference to formal of inherited operation or to primitive |
26403 | 26407 | -- operation of root type, with corresponding entity for derived type, |
@@ -26503,6 +26507,17 @@ package body Sem_Prag is | ||
26503 | 26507 | -- Start of processing for Build_Classwide_Expression |
26504 | 26508 | |
26505 | 26509 | begin |
26510 | + -- Add mapping from old formals to new formals. | |
26511 | + | |
26512 | + Par_Formal := First_Formal (Par_Subp); | |
26513 | + Subp_Formal := First_Formal (Subp); | |
26514 | + | |
26515 | + while Present (Par_Formal) and then Present (Subp_Formal) loop | |
26516 | + Primitives_Mapping.Set (Par_Formal, Subp_Formal); | |
26517 | + Next_Formal (Par_Formal); | |
26518 | + Next_Formal (Subp_Formal); | |
26519 | + end loop; | |
26520 | + | |
26506 | 26521 | Replace_Condition_Entities (Prag); |
26507 | 26522 | end Build_Classwide_Expression; |
26508 | 26523 |
@@ -26555,10 +26570,8 @@ package body Sem_Prag is | ||
26555 | 26570 | Loc : constant Source_Ptr := Sloc (Prag); |
26556 | 26571 | Prag_Nam : constant Name_Id := Pragma_Name (Prag); |
26557 | 26572 | Check_Prag : Node_Id; |
26558 | - Inher_Formal : Entity_Id; | |
26559 | 26573 | Msg_Arg : Node_Id; |
26560 | 26574 | Nam : Name_Id; |
26561 | - Subp_Formal : Entity_Id; | |
26562 | 26575 | |
26563 | 26576 | -- Start of processing for Build_Pragma_Check_Equivalent |
26564 | 26577 |
@@ -26573,16 +26586,6 @@ package body Sem_Prag is | ||
26573 | 26586 | |
26574 | 26587 | Update_Primitives_Mapping (Inher_Id, Subp_Id); |
26575 | 26588 | |
26576 | - -- Add mapping from old formals to new formals. | |
26577 | - | |
26578 | - Inher_Formal := First_Formal (Inher_Id); | |
26579 | - Subp_Formal := First_Formal (Subp_Id); | |
26580 | - while Present (Inher_Formal) and then Present (Subp_Formal) loop | |
26581 | - Primitives_Mapping.Set (Inher_Formal, Subp_Formal); | |
26582 | - Next_Formal (Inher_Formal); | |
26583 | - Next_Formal (Subp_Formal); | |
26584 | - end loop; | |
26585 | - | |
26586 | 26589 | -- Use generic machinery to copy inherited pragma, as if it were an |
26587 | 26590 | -- instantiation, resetting source locations appropriately, so that |
26588 | 26591 | -- expressions inside the inherited pragma use chained locations. |
@@ -26592,9 +26595,13 @@ package body Sem_Prag is | ||
26592 | 26595 | Set_Copied_Sloc_For_Inherited_Pragma |
26593 | 26596 | (Unit_Declaration_Node (Subp_Id), Inher_Id); |
26594 | 26597 | Check_Prag := New_Copy_Tree (Source => Prag); |
26595 | - Build_Classwide_Expression (Check_Prag, Subp_Id, Adjust_Sloc => True); | |
26596 | 26598 | |
26597 | - -- Otherwise simply copy the original pragma | |
26599 | + -- Build the inherited classwide condition. | |
26600 | + | |
26601 | + Build_Classwide_Expression | |
26602 | + (Check_Prag, Subp_Id, Inher_Id, Adjust_Sloc => True); | |
26603 | + | |
26604 | + -- If not an inherited condition simply copy the original pragma | |
26598 | 26605 | |
26599 | 26606 | else |
26600 | 26607 | Check_Prag := New_Copy_Tree (Source => Prag); |
@@ -29301,7 +29308,8 @@ package body Sem_Prag is | ||
29301 | 29308 | Subp_Id : Entity_Id) |
29302 | 29309 | is |
29303 | 29310 | function Overridden_Ancestor (S : Entity_Id) return Entity_Id; |
29304 | - -- ??? what does this routine do? | |
29311 | + -- Locate the primitive operation with the name of S whose controlling | |
29312 | + -- type is the dispatching type of Inher_Id. | |
29305 | 29313 | |
29306 | 29314 | ------------------------- |
29307 | 29315 | -- Overridden_Ancestor -- |
@@ -29333,7 +29341,7 @@ package body Sem_Prag is | ||
29333 | 29341 | Old_Prim : Entity_Id; |
29334 | 29342 | Prim : Entity_Id; |
29335 | 29343 | |
29336 | - -- Start of processing for Primitive_Mapping | |
29344 | + -- Start of processing for Update_Primitives_Mapping | |
29337 | 29345 | |
29338 | 29346 | begin |
29339 | 29347 | -- If the types are already in the map, it has been previously built for |
@@ -247,10 +247,12 @@ package Sem_Prag is | ||
247 | 247 | procedure Build_Classwide_Expression |
248 | 248 | (Prag : Node_Id; |
249 | 249 | Subp : Entity_Id; |
250 | + Par_Subp : Entity_Id; | |
250 | 251 | Adjust_Sloc : Boolean); |
251 | 252 | -- Build the expression for an inherited classwide condition. Prag is |
252 | 253 | -- the pragma constructed from the corresponding aspect of the parent |
253 | - -- subprogram, and Subp is the overridding operation. Adjust_Sloc is True | |
254 | + -- subprogram, and Subp is the overridding operation and Par_Subp is | |
255 | + -- the overridden operation that has the condition. Adjust_Sloc is True | |
254 | 256 | -- when the sloc of nodes traversed should be adjusted for the inherited |
255 | 257 | -- pragma. The routine is also called to check whether an inherited |
256 | 258 | -- operation that is not overridden but has inherited conditions need |