Commit d145e562 by Arnaud Charlet Committed by Pierre-Marie de Rodat

[Ada] Fix handling of -gnatceg on incomplete unit

2019-10-10  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

	* gnat1drv.adb (Gnat1drv): Skip code generation when handling an
	incomplete unit with -gnatceg.

From-SVN: r276817
parent f68289d8
2019-10-10 Gary Dismukes <dismukes@adacore.com>
2019-10-10 Arnaud Charlet <charlet@adacore.com>
* exp_ch7.adb (Check_Unnesting_Elaboration_Code): Various
cleanups.
(Set_Elab_Proc): New procedure to create the defining identifier
for a procedure created to encapsulate top-level blocks
occurring as a part of library package elaboration.
(First_Local_Scope): Function replaced by
Reset_Scopes_To_Elab_Proc.
(Reset_Scopes_To_Elab_Proc): New recursive procedure based on
First_Local_Scope, which it replaces, that is called to traverse
the statements of a library package body to locate top-level
blocks and determine whether they contain nested subprograms
that might address library-level objects of the package. Such
blocks (and loops) and certain top-level subprograms within the
statements will have their Scope reset here to match an
encapsulating procedure created by
Check_Unnesting_Elaboration_Code that will contain the
statements.
(Check_Unnesting_In_Decls_Or_Stmts): Code for handling blocks
factored out into Unnest_Block. Add handling for package
declarations and bodies, making recursive calls for
visible/private declarations, body declarations, statements, and
exception handlers. Also remove test for Is_Compilation_Unit:
caller tests for Is_Library_Level_Entity instead. Also, this
proc's name was changed from Check_Unnesting_In_Declarations.
(Check_Unnesting_In_Handlers): New procedure to traverse a
sequence of exception handlers, calling
Check_Unnesting_In_Decls_Or_Stmts on the statements of each
handler.
(Expand_N_Package_Body): Call Check_Unnesting_* routines only
when Unnest_Subprogram_Mode is set and the current scope is a
library-level entity (which includes packages and instantiations
nested directly within a library unit).
(Expand_N_Package_Declaration): Call Check_Unnesting_* routines
only when Unnest_Subprogram_Mode is set and the current scope is
a library-level entity (which includes packages and
instantiations nested directly within a library unit).
(Unnest_Block): New procedure factored out of
Check_Unnesting_In_Decls_Or_Stmts, for creating a new procedure
to replace a block statement and resetting the Scope fields of
the block's top-level entities.
\ No newline at end of file
* gnat1drv.adb (Gnat1drv): Skip code generation when handling an
incomplete unit with -gnatceg.
\ No newline at end of file
......@@ -1412,11 +1412,25 @@ begin
-- It is not an error to analyze in CodePeer mode a spec which requires
-- a body, in order to generate SCIL for this spec.
-- Ditto for Generate_C_Code mode and generate a C header for a spec.
elsif CodePeer_Mode or Generate_C_Code then
elsif CodePeer_Mode then
Back_End_Mode := Generate_Object;
-- Differentiate use of -gnatceg to generate a C header from an Ada spec
-- to the CCG case (standard.h found) where C code generation should
-- only be performed on full units.
elsif Generate_C_Code then
Name_Len := 10;
Name_Buffer (1 .. Name_Len) := "standard.h";
if Find_File (Name_Find, Osint.Source, Full_Name => True) = No_File
then
Back_End_Mode := Generate_Object;
else
Back_End_Mode := Skip;
end if;
-- It is not an error to analyze in GNATprove mode a spec which requires
-- a body, when the body is not available. During frame condition
-- generation, the corresponding ALI file is generated. During
......
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