From d145e5628f3a72abb2991e2fe9f45af963500ee5 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Thu, 10 Oct 2019 15:23:28 +0000 Subject: [PATCH] [Ada] Fix handling of -gnatceg on incomplete unit 2019-10-10 Arnaud Charlet gcc/ada/ * gnat1drv.adb (Gnat1drv): Skip code generation when handling an incomplete unit with -gnatceg. From-SVN: r276817 --- gcc/ada/ChangeLog | 44 +++----------------------------------------- gcc/ada/gnat1drv.adb | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 43 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 866de1f..f4484cb 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,42 +1,4 @@ -2019-10-10 Gary Dismukes +2019-10-10 Arnaud Charlet - * 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 diff --git a/gcc/ada/gnat1drv.adb b/gcc/ada/gnat1drv.adb index af07a06..7d507aa 100644 --- a/gcc/ada/gnat1drv.adb +++ b/gcc/ada/gnat1drv.adb @@ -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 -- 2.7.4