Mercurial > hg > CbC > CbC_gcc
comparison gcc/ada/gnat1drv.adb @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 84e7813d76e9 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
4 -- -- | 4 -- -- |
5 -- G N A T 1 D R V -- | 5 -- G N A T 1 D R V -- |
6 -- -- | 6 -- -- |
7 -- B o d y -- | 7 -- B o d y -- |
8 -- -- | 8 -- -- |
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. -- | 9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. -- |
10 -- -- | 10 -- -- |
11 -- GNAT is free software; you can redistribute it and/or modify it under -- | 11 -- GNAT is free software; you can redistribute it and/or modify it under -- |
12 -- terms of the GNU General Public License as published by the Free Soft- -- | 12 -- terms of the GNU General Public License as published by the Free Soft- -- |
13 -- ware Foundation; either version 3, or (at your option) any later ver- -- | 13 -- ware Foundation; either version 3, or (at your option) any later ver- -- |
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- | 14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
49 with Osint.C; use Osint.C; | 49 with Osint.C; use Osint.C; |
50 with Output; use Output; | 50 with Output; use Output; |
51 with Par_SCO; | 51 with Par_SCO; |
52 with Prepcomp; | 52 with Prepcomp; |
53 with Repinfo; | 53 with Repinfo; |
54 with Repinfo.Input; | |
54 with Restrict; | 55 with Restrict; |
55 with Rident; use Rident; | 56 with Rident; use Rident; |
56 with Rtsfind; | 57 with Rtsfind; |
57 with SCOs; | 58 with SCOs; |
58 with Sem; | 59 with Sem; |
59 with Sem_Ch8; | 60 with Sem_Ch8; |
60 with Sem_Ch12; | 61 with Sem_Ch12; |
61 with Sem_Ch13; | 62 with Sem_Ch13; |
62 with Sem_Elim; | 63 with Sem_Elim; |
63 with Sem_Eval; | 64 with Sem_Eval; |
64 with Sem_SPARK; use Sem_SPARK; | 65 with Sem_Prag; |
65 with Sem_Type; | 66 with Sem_Type; |
66 with Set_Targ; | 67 with Set_Targ; |
67 with Sinfo; use Sinfo; | 68 with Sinfo; use Sinfo; |
69 with Sinput; use Sinput; | |
68 with Sinput.L; use Sinput.L; | 70 with Sinput.L; use Sinput.L; |
69 with Snames; use Snames; | 71 with Snames; use Snames; |
70 with Sprint; use Sprint; | 72 with Sprint; use Sprint; |
71 with Stringt; | 73 with Stringt; |
72 with Stylesw; use Stylesw; | 74 with Stylesw; use Stylesw; |
79 with Uintp; | 81 with Uintp; |
80 with Uname; use Uname; | 82 with Uname; use Uname; |
81 with Urealp; | 83 with Urealp; |
82 with Usage; | 84 with Usage; |
83 with Validsw; use Validsw; | 85 with Validsw; use Validsw; |
86 with Warnsw; use Warnsw; | |
84 | 87 |
85 with System.Assertions; | 88 with System.Assertions; |
86 with System.OS_Lib; | 89 with System.OS_Lib; |
87 | 90 |
88 -------------- | 91 -------------- |
110 -- to the end of the compilation process, after generating code but before | 113 -- to the end of the compilation process, after generating code but before |
111 -- issuing error messages. In particular, these checks generally require | 114 -- issuing error messages. In particular, these checks generally require |
112 -- the information provided by the back end in back annotation of declared | 115 -- the information provided by the back end in back annotation of declared |
113 -- entities (e.g. actual size and alignment values chosen by the back end). | 116 -- entities (e.g. actual size and alignment values chosen by the back end). |
114 | 117 |
118 procedure Read_JSON_Files_For_Repinfo; | |
119 -- This procedure exercises the JSON parser of Repinfo by reading back the | |
120 -- JSON files generated by -gnatRjs in a previous compilation session. It | |
121 -- is intended to make sure that the JSON generator and the JSON parser are | |
122 -- kept synchronized when the JSON format evolves. | |
123 | |
115 ---------------------------- | 124 ---------------------------- |
116 -- Adjust_Global_Switches -- | 125 -- Adjust_Global_Switches -- |
117 ---------------------------- | 126 ---------------------------- |
118 | 127 |
119 procedure Adjust_Global_Switches is | 128 procedure Adjust_Global_Switches is |
316 (Alignment_Check => True, | 325 (Alignment_Check => True, |
317 Division_Check => True, | 326 Division_Check => True, |
318 Elaboration_Check => True, | 327 Elaboration_Check => True, |
319 others => False); | 328 others => False); |
320 | 329 |
321 Dynamic_Elaboration_Checks := False; | 330 -- Need to enable dynamic elaboration checks to disable strict |
331 -- static checking performed by gnatbind. We are at the same time | |
332 -- suppressing actual compile time elaboration checks to simplify | |
333 -- the generated code. | |
334 | |
335 Dynamic_Elaboration_Checks := True; | |
322 | 336 |
323 -- Set STRICT mode for overflow checks if not set explicitly. This | 337 -- Set STRICT mode for overflow checks if not set explicitly. This |
324 -- prevents suppressing of overflow checks by default, in code down | 338 -- prevents suppressing of overflow checks by default, in code down |
325 -- below. | 339 -- below. |
326 | 340 |
377 -- All other validity checking is turned off, since this can generate | 391 -- All other validity checking is turned off, since this can generate |
378 -- very complex trees that only confuse CodePeer and do not bring | 392 -- very complex trees that only confuse CodePeer and do not bring |
379 -- enough useful info. | 393 -- enough useful info. |
380 | 394 |
381 Reset_Validity_Check_Options; | 395 Reset_Validity_Check_Options; |
382 Validity_Check_Default := True; | 396 Set_Validity_Check_Options ("dc"); |
383 Validity_Check_Copies := True; | |
384 Check_Validity_Of_Parameters := False; | 397 Check_Validity_Of_Parameters := False; |
385 | 398 |
386 -- Turn off style check options and ignore any style check pragmas | 399 -- Turn off style check options and ignore any style check pragmas |
387 -- since we are not interested in any front-end warnings when we are | 400 -- since we are not interested in any front-end warnings when we are |
388 -- getting CodePeer output. | 401 -- getting CodePeer output. |
401 -- is in the business of finding problems, not enforcing rules. | 414 -- is in the business of finding problems, not enforcing rules. |
402 -- This is useful when using CodePeer mode with other compilers. | 415 -- This is useful when using CodePeer mode with other compilers. |
403 | 416 |
404 Relaxed_RM_Semantics := True; | 417 Relaxed_RM_Semantics := True; |
405 | 418 |
406 if not Generate_CodePeer_Messages then | 419 if Generate_CodePeer_Messages then |
420 | |
421 -- We do want to emit GNAT warnings when using -gnateC. But, | |
422 -- in CodePeer mode, warnings about memory representation are not | |
423 -- meaningful, thus, suppress them. | |
424 | |
425 Warn_On_Biased_Representation := False; -- -gnatw.b | |
426 Warn_On_Unrepped_Components := False; -- -gnatw.c | |
427 Warn_On_Record_Holes := False; -- -gnatw.h | |
428 Warn_On_Unchecked_Conversion := False; -- -gnatwz | |
429 Warn_On_Size_Alignment := False; -- -gnatw.z | |
430 Warn_On_Questionable_Layout := False; -- -gnatw.q | |
431 Warn_On_Overridden_Size := False; -- -gnatw.s | |
432 Warn_On_Reverse_Bit_Order := False; -- -gnatw.v | |
433 | |
434 else | |
407 | 435 |
408 -- Suppress compiler warnings by default when generating SCIL for | 436 -- Suppress compiler warnings by default when generating SCIL for |
409 -- CodePeer, except when combined with -gnateC where we do want to | 437 -- CodePeer, except when combined with -gnateC where we do want to |
410 -- emit GNAT warnings. | 438 -- emit GNAT warnings. |
411 | 439 |
773 | 801 |
774 -- No back-end inlining available on C generation | 802 -- No back-end inlining available on C generation |
775 | 803 |
776 not Generate_C_Code | 804 not Generate_C_Code |
777 | 805 |
806 -- No back-end inlining available in ASIS mode | |
807 | |
808 and then not ASIS_Mode | |
809 | |
778 -- No back-end inlining in GNATprove mode, since it just confuses | 810 -- No back-end inlining in GNATprove mode, since it just confuses |
779 -- the formal verification process. | 811 -- the formal verification process. |
780 | 812 |
781 and then not GNATprove_Mode | 813 and then not GNATprove_Mode |
782 | 814 |
988 -- and alignment annotated by the backend where possible). We need to | 1020 -- and alignment annotated by the backend where possible). We need to |
989 -- unlock temporarily these tables to reanalyze their expression. | 1021 -- unlock temporarily these tables to reanalyze their expression. |
990 | 1022 |
991 Atree.Unlock; | 1023 Atree.Unlock; |
992 Nlists.Unlock; | 1024 Nlists.Unlock; |
1025 Elists.Unlock; | |
993 Sem.Unlock; | 1026 Sem.Unlock; |
994 Sem_Ch13.Validate_Compile_Time_Warning_Errors; | 1027 Sem_Prag.Validate_Compile_Time_Warning_Errors; |
995 Sem.Lock; | 1028 Sem.Lock; |
1029 Elists.Lock; | |
996 Nlists.Lock; | 1030 Nlists.Lock; |
997 Atree.Lock; | 1031 Atree.Lock; |
998 | 1032 |
999 -- Validate unchecked conversions (using the values for size and | 1033 -- Validate unchecked conversions (using the values for size and |
1000 -- alignment annotated by the backend where possible). | 1034 -- alignment annotated by the backend where possible). |
1013 -- | 1047 -- |
1014 -- if AAMP_On_Target then | 1048 -- if AAMP_On_Target then |
1015 -- Sem_Ch13.Validate_Independence; | 1049 -- Sem_Ch13.Validate_Independence; |
1016 -- end if; | 1050 -- end if; |
1017 end Post_Compilation_Validation_Checks; | 1051 end Post_Compilation_Validation_Checks; |
1052 | |
1053 ----------------------------------- | |
1054 -- Read_JSON_Files_For_Repinfo -- | |
1055 ----------------------------------- | |
1056 | |
1057 procedure Read_JSON_Files_For_Repinfo is | |
1058 begin | |
1059 -- This is the same loop construct as in Repinfo.List_Rep_Info | |
1060 | |
1061 for U in Main_Unit .. Last_Unit loop | |
1062 if In_Extended_Main_Source_Unit (Cunit_Entity (U)) then | |
1063 declare | |
1064 Nam : constant String := | |
1065 Get_Name_String | |
1066 (File_Name (Source_Index (U))) & ".json"; | |
1067 Namid : constant File_Name_Type := Name_Enter (Nam); | |
1068 Index : constant Source_File_Index := Load_Config_File (Namid); | |
1069 | |
1070 begin | |
1071 if Index = No_Source_File then | |
1072 Write_Str ("cannot locate "); | |
1073 Write_Line (Nam); | |
1074 raise Unrecoverable_Error; | |
1075 end if; | |
1076 | |
1077 Repinfo.Input.Read_JSON_Stream (Source_Text (Index).all, Nam); | |
1078 exception | |
1079 when Repinfo.Input.Invalid_JSON_Stream => | |
1080 raise Unrecoverable_Error; | |
1081 end; | |
1082 end if; | |
1083 end loop; | |
1084 end Read_JSON_Files_For_Repinfo; | |
1018 | 1085 |
1019 -- Local variables | 1086 -- Local variables |
1020 | 1087 |
1021 Back_End_Mode : Back_End.Back_End_Mode_Type; | 1088 Back_End_Mode : Back_End.Back_End_Mode_Type; |
1022 Ecode : Exit_Code_Type; | 1089 Ecode : Exit_Code_Type; |
1080 if Operating_Mode /= Check_Syntax then | 1147 if Operating_Mode /= Check_Syntax then |
1081 | 1148 |
1082 -- Acquire target parameters from system.ads (package System source) | 1149 -- Acquire target parameters from system.ads (package System source) |
1083 | 1150 |
1084 Targparm_Acquire : declare | 1151 Targparm_Acquire : declare |
1085 use Sinput; | |
1086 | 1152 |
1087 S : Source_File_Index; | 1153 S : Source_File_Index; |
1088 N : File_Name_Type; | 1154 N : File_Name_Type; |
1089 | 1155 |
1090 begin | 1156 begin |
1159 -- Check we do not have more than one source file, this happens only in | 1225 -- Check we do not have more than one source file, this happens only in |
1160 -- the case where the driver is called directly, it cannot happen when | 1226 -- the case where the driver is called directly, it cannot happen when |
1161 -- gnat1 is invoked from gcc in the normal case. | 1227 -- gnat1 is invoked from gcc in the normal case. |
1162 | 1228 |
1163 if Osint.Number_Of_Files /= 1 then | 1229 if Osint.Number_Of_Files /= 1 then |
1164 Usage; | 1230 |
1165 Write_Eol; | 1231 -- In GNATprove mode, gcc is not called, so we may end up with |
1232 -- switches wrongly interpreted as source file names when they are | |
1233 -- written by mistake without a starting hyphen. Issue a specific | |
1234 -- error message but do not print the internal 'usage' message. | |
1235 | |
1236 if GNATprove_Mode then | |
1237 Write_Str | |
1238 ("one of the following is not a valid switch or source file " | |
1239 & "name: "); | |
1240 Osint.Dump_Command_Line_Source_File_Names; | |
1241 else | |
1242 Usage; | |
1243 Write_Eol; | |
1244 end if; | |
1245 | |
1166 Osint.Fail ("you must provide one source file"); | 1246 Osint.Fail ("you must provide one source file"); |
1167 | 1247 |
1168 elsif Usage_Requested then | 1248 elsif Usage_Requested then |
1169 Usage; | 1249 Usage; |
1170 end if; | 1250 end if; |
1330 elsif Main_Unit_Kind in N_Generic_Renaming_Declaration then | 1410 elsif Main_Unit_Kind in N_Generic_Renaming_Declaration then |
1331 Back_End_Mode := Generate_Object; | 1411 Back_End_Mode := Generate_Object; |
1332 | 1412 |
1333 -- It is not an error to analyze in CodePeer mode a spec which requires | 1413 -- It is not an error to analyze in CodePeer mode a spec which requires |
1334 -- a body, in order to generate SCIL for this spec. | 1414 -- a body, in order to generate SCIL for this spec. |
1335 -- Ditto for Generate_C_Code mode and generate a C header for a spec. | 1415 |
1336 | 1416 elsif CodePeer_Mode then |
1337 elsif CodePeer_Mode or Generate_C_Code then | |
1338 Back_End_Mode := Generate_Object; | 1417 Back_End_Mode := Generate_Object; |
1418 | |
1419 -- Differentiate use of -gnatceg to generate a C header from an Ada spec | |
1420 -- to the CCG case (standard.h found) where C code generation should | |
1421 -- only be performed on full units. | |
1422 | |
1423 elsif Generate_C_Code then | |
1424 Name_Len := 10; | |
1425 Name_Buffer (1 .. Name_Len) := "standard.h"; | |
1426 | |
1427 if Find_File (Name_Find, Osint.Source, Full_Name => True) = No_File | |
1428 then | |
1429 Back_End_Mode := Generate_Object; | |
1430 else | |
1431 Back_End_Mode := Skip; | |
1432 end if; | |
1339 | 1433 |
1340 -- It is not an error to analyze in GNATprove mode a spec which requires | 1434 -- It is not an error to analyze in GNATprove mode a spec which requires |
1341 -- a body, when the body is not available. During frame condition | 1435 -- a body, when the body is not available. During frame condition |
1342 -- generation, the corresponding ALI file is generated. During | 1436 -- generation, the corresponding ALI file is generated. During |
1343 -- analysis, the spec is analyzed. | 1437 -- analysis, the spec is analyzed. |
1436 Errout.Output_Messages; | 1530 Errout.Output_Messages; |
1437 Treepr.Tree_Dump; | 1531 Treepr.Tree_Dump; |
1438 Tree_Gen; | 1532 Tree_Gen; |
1439 | 1533 |
1440 -- Generate ALI file if specially requested, or for missing subunits, | 1534 -- Generate ALI file if specially requested, or for missing subunits, |
1441 -- subunits or predefined generic. | 1535 -- subunits or predefined generic. For ignored ghost code, the object |
1442 | 1536 -- file IS generated, so Object should be True, and since the object |
1443 if Opt.Force_ALI_Tree_File then | 1537 -- file is generated, we need to generate the ALI file. We never want |
1444 Write_ALI (Object => False); | 1538 -- an object file without an ALI file. |
1539 | |
1540 if Is_Ignored_Ghost_Unit (Main_Unit_Node) | |
1541 or else Opt.Force_ALI_Tree_File | |
1542 then | |
1543 Write_ALI (Object => Is_Ignored_Ghost_Unit (Main_Unit_Node)); | |
1445 end if; | 1544 end if; |
1446 | 1545 |
1447 Namet.Finalize; | 1546 Namet.Finalize; |
1448 Check_Rep_Info; | 1547 Check_Rep_Info; |
1449 | 1548 |
1504 | 1603 |
1505 Prepcomp.Add_Dependencies; | 1604 Prepcomp.Add_Dependencies; |
1506 | 1605 |
1507 if GNATprove_Mode then | 1606 if GNATprove_Mode then |
1508 | 1607 |
1509 -- Perform the new SPARK checking rules for pointer aliasing. This is | |
1510 -- only activated in GNATprove mode and on SPARK code. | |
1511 | |
1512 if Debug_Flag_FF then | |
1513 Check_Safe_Pointers (Main_Unit_Node); | |
1514 end if; | |
1515 | |
1516 -- In GNATprove mode we're writing the ALI much earlier than usual | 1608 -- In GNATprove mode we're writing the ALI much earlier than usual |
1517 -- as flow analysis needs the file present in order to append its | 1609 -- as flow analysis needs the file present in order to append its |
1518 -- own globals to it. | 1610 -- own globals to it. |
1519 | 1611 |
1520 -- Note: In GNATprove mode, an "object" file is always generated as | 1612 -- Note: In GNATprove mode, an "object" file is always generated as |
1527 -- Some back ends (for instance Gigi) are known to rely on SCOs for code | 1619 -- Some back ends (for instance Gigi) are known to rely on SCOs for code |
1528 -- generation. Make sure they are available. | 1620 -- generation. Make sure they are available. |
1529 | 1621 |
1530 if Generate_SCO then | 1622 if Generate_SCO then |
1531 Par_SCO.SCO_Record_Filtered; | 1623 Par_SCO.SCO_Record_Filtered; |
1624 end if; | |
1625 | |
1626 -- If -gnatd_j is specified, exercise the JSON parser of Repinfo | |
1627 | |
1628 if Debug_Flag_Underscore_J then | |
1629 Read_JSON_Files_For_Repinfo; | |
1532 end if; | 1630 end if; |
1533 | 1631 |
1534 -- Back end needs to explicitly unlock tables it needs to touch | 1632 -- Back end needs to explicitly unlock tables it needs to touch |
1535 | 1633 |
1536 Atree.Lock; | 1634 Atree.Lock; |