diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-04 13:27:57 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-10-04 13:27:57 +0000 |
commit | 61e77e4568a4510e54c4d17733a8ed29cd1ae77b (patch) | |
tree | 762cf5586088eb7449e204245ad71d64685bca32 | |
parent | f6742bc085755096f16bd4f80d89b53e5508d0be (diff) | |
download | gcc-61e77e4568a4510e54c4d17733a8ed29cd1ae77b.tar.gz |
2010-10-04 Vincent Celier <celier@adacore.com>
* frontend.adb: Set Lib.Parsing_Main_Extended_Source to True before
loading the main source, so that if it is preprocessed and -gnateG is
used, the preprocessed file is written.
* lib.ads (Analysing_Subunit_Of_Main): New global variable to indicate
if a subunit is from the main unit when it is loaded.
* sem_ch10.adb (Analyze_Proper_Body): Set Lib.Analysing_Subunit_Of_Main
to True before loading a subunit.
* sem_ch12.adb (Copy_Generic_Node): Set Lib.Analysing_Subunit_Of_Main
to True when the main is a generic unit before loading one of its
subunits.
* sinput-l.adb (Load_File): If -gnateG is used, write the preprocessed
file only for the main unit (spec, body and subunits).
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164934 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/ada/frontend.adb | 10 | ||||
-rw-r--r-- | gcc/ada/lib.ads | 5 | ||||
-rw-r--r-- | gcc/ada/sem_ch10.adb | 15 | ||||
-rw-r--r-- | gcc/ada/sem_ch12.adb | 7 | ||||
-rw-r--r-- | gcc/ada/sinput-l.adb | 15 |
6 files changed, 54 insertions, 13 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 8596df4fb29..0c292b9e5d1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,5 +1,20 @@ 2010-10-04 Vincent Celier <celier@adacore.com> + * frontend.adb: Set Lib.Parsing_Main_Extended_Source to True before + loading the main source, so that if it is preprocessed and -gnateG is + used, the preprocessed file is written. + * lib.ads (Analysing_Subunit_Of_Main): New global variable to indicate + if a subunit is from the main unit when it is loaded. + * sem_ch10.adb (Analyze_Proper_Body): Set Lib.Analysing_Subunit_Of_Main + to True before loading a subunit. + * sem_ch12.adb (Copy_Generic_Node): Set Lib.Analysing_Subunit_Of_Main + to True when the main is a generic unit before loading one of its + subunits. + * sinput-l.adb (Load_File): If -gnateG is used, write the preprocessed + file only for the main unit (spec, body and subunits). + +2010-10-04 Vincent Celier <celier@adacore.com> + * sinput-l.adb (Load_File): Do not fail when switch -gnateG is specified and the processed file cannot be written. Just issue a warning and continue. diff --git a/gcc/ada/frontend.adb b/gcc/ada/frontend.adb index 31c8feaa9c1..fd83b5d5b5c 100644 --- a/gcc/ada/frontend.adb +++ b/gcc/ada/frontend.adb @@ -116,6 +116,11 @@ begin Prepcomp.Check_Symbols; end if; + -- We set Parsing_Main_Extended_Source true here to cover processing of all + -- the configuration pragma files, as well as the main source unit itself. + + Parsing_Main_Extended_Source := True; + -- Now that the preprocessing situation is established, we are able to -- load the main source (this is no longer done by Lib.Load.Initialize). @@ -127,11 +132,6 @@ begin return; end if; - -- We set Parsing_Main_Extended_Source true here to cover processing of all - -- the configuration pragma files, as well as the main source unit itself. - - Parsing_Main_Extended_Source := True; - -- Read and process configuration pragma files if present declare diff --git a/gcc/ada/lib.ads b/gcc/ada/lib.ads index 0aac6f04da4..28e2ec064cd 100644 --- a/gcc/ada/lib.ads +++ b/gcc/ada/lib.ads @@ -49,6 +49,11 @@ package Lib is -- extended source (the main unit, its spec, or one of its subunits). This -- flag to implement In_Extended_Main_Source_Unit. + Analysing_Subunit_Of_Main : Boolean := False; + -- Set to True when analyzing a subunit of the main source. When True, if + -- the subunit is preprocessed and -gnateG is specified, then the + -- preprocessed file (.prep) is written. + -------------------------------------------- -- General Approach to Library Management -- -------------------------------------------- diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb index 7623b8231ea..f38503d00da 100644 --- a/gcc/ada/sem_ch10.adb +++ b/gcc/ada/sem_ch10.adb @@ -1739,12 +1739,17 @@ package body Sem_Ch10 is -- Otherwise we must load the subunit and link to it else + -- Make sure that, if the subunit is preprocessed and -gnateG is + -- specified, the preprocessed file will be written. + + Lib.Analysing_Subunit_Of_Main := True; Unum := Load_Unit (Load_Name => Subunit_Name, Required => False, Subunit => True, Error_Node => N); + Lib.Analysing_Subunit_Of_Main := False; -- Give message if we did not get the unit Emit warning even if -- missing subunit is not within main unit, to simplify debugging. @@ -1822,11 +1827,11 @@ package body Sem_Ch10 is end if; end if; - -- The remaining case is when the subunit is not already loaded and - -- we are not generating code. In this case we are just performing - -- semantic analysis on the parent, and we are not interested in - -- the subunit. For subprograms, analyze the stub as a body. For - -- other entities the stub has already been marked as completed. + -- The remaining case is when the subunit is not already loaded and we + -- are not generating code. In this case we are just performing semantic + -- analysis on the parent, and we are not interested in the subunit. For + -- subprograms, analyze the stub as a body. For other entities the stub + -- has already been marked as completed. else Optional_Subunit; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index b325ccbe89c..5f258f23d68 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -5906,12 +5906,19 @@ package body Sem_Ch12 is New_Body : Node_Id; begin + -- Make sure that, if it is a subunit of the main unit that is + -- preprocessed and if -gnateG is specified, the preprocessed + -- file will be written. + + Lib.Analysing_Subunit_Of_Main := + Lib.In_Extended_Main_Source_Unit (N); Unum := Load_Unit (Load_Name => Subunit_Name, Required => False, Subunit => True, Error_Node => N); + Lib.Analysing_Subunit_Of_Main := False; -- If the proper body is not found, a warning message will be -- emitted when analyzing the stub, or later at the point diff --git a/gcc/ada/sinput-l.adb b/gcc/ada/sinput-l.adb index 98ad104d020..8d952b2cd04 100644 --- a/gcc/ada/sinput-l.adb +++ b/gcc/ada/sinput-l.adb @@ -30,6 +30,7 @@ with Einfo; use Einfo; with Errout; use Errout; with Fname; use Fname; with Hostparm; +with Lib; use Lib; with Opt; use Opt; with Osint; use Osint; with Output; use Output; @@ -552,9 +553,17 @@ package body Sinput.L is else -- Output the result of the preprocessing, if requested and - -- the source has been modified by the preprocessing. - - if Generate_Processed_File and then Modified then + -- the source has been modified by the preprocessing. Only + -- do that for the main unit (spec, body and subunits). + + if Generate_Processed_File and then + Modified and then + ((Compiler_State = Parsing + and then Parsing_Main_Extended_Source) + or else + (Compiler_State = Analyzing + and then Analysing_Subunit_Of_Main)) + then declare FD : File_Descriptor; NB : Integer; |