From 97edd4267e6fef2da066feafc39c107f2687ee37 Mon Sep 17 00:00:00 2001 From: Arnaud Charlet Date: Wed, 3 Jul 2019 08:14:00 +0000 Subject: [PATCH] [Ada] Add a gnatbind option to generate C code 2019-07-03 Arnaud Charlet gcc/ada/ * bindgen.adb (Gen_Main): Disable generation of reference to Ada_Main_Program_Name for CCG. * bindusg.adb (Display): Add -G to the command-line usage for gnatbind. * opt.ads (Generate_C_Code): Update comment. * switch-b.adb (Scan_Binder_Switches): Add handling for -G. From-SVN: r272965 --- gcc/ada/ChangeLog | 9 +++++++++ gcc/ada/bindgen.adb | 9 +++++++-- gcc/ada/bindusg.adb | 5 +++++ gcc/ada/opt.ads | 4 ++-- gcc/ada/switch-b.adb | 6 ++++++ 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index d1b11cee9e2..755c9fb2bf7 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,12 @@ +2019-07-03 Arnaud Charlet + + * bindgen.adb (Gen_Main): Disable generation of reference to + Ada_Main_Program_Name for CCG. + * bindusg.adb (Display): Add -G to the command-line usage for + gnatbind. + * opt.ads (Generate_C_Code): Update comment. + * switch-b.adb (Scan_Binder_Switches): Add handling for -G. + 2019-07-03 Arnaud Charlet * sem_ch7.adb (Has_Referencer): Do not consider inlined diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb index b5637a49c4a..9efc873c3e4 100644 --- a/gcc/ada/bindgen.adb +++ b/gcc/ada/bindgen.adb @@ -1805,13 +1805,18 @@ package body Bindgen is -- referenced elsewhere in the generated program, but is needed by -- the debugger (that's why it is generated in the first place). The -- reference stops Ada_Main_Program_Name from being optimized away by - -- smart linkers, such as the AiX linker. + -- smart linkers. -- Because this variable is unused, we make this variable "aliased" -- with a pragma Volatile in order to tell the compiler to preserve -- this variable at any level of optimization. - if Bind_Main_Program and not CodePeer_Mode then + -- CodePeer and CCG do not need this extra code on the other hand. + + if Bind_Main_Program + and then not CodePeer_Mode + and then not Generate_C_Code + then WBI (" Ensure_Reference : aliased System.Address := " & "Ada_Main_Program_Name'Address;"); WBI (" pragma Volatile (Ensure_Reference);"); diff --git a/gcc/ada/bindusg.adb b/gcc/ada/bindusg.adb index d4ac1b36598..8c51d116fee 100644 --- a/gcc/ada/bindusg.adb +++ b/gcc/ada/bindusg.adb @@ -133,6 +133,11 @@ package body Bindusg is Write_Line (" -F Force checking of elaboration Flags"); + -- Line for -G switch + + Write_Line + (" -G Generate binder file suitable for CCG"); + -- Line for -h switch Write_Line diff --git a/gcc/ada/opt.ads b/gcc/ada/opt.ads index 4ee5fdbf2bc..16b5cbae00a 100644 --- a/gcc/ada/opt.ads +++ b/gcc/ada/opt.ads @@ -746,9 +746,9 @@ package Opt is -- file name with extension stripped. Generate_C_Code : Boolean := False; - -- GNAT + -- GNAT, GNATBIND -- If True, the Cprint circuitry to generate C code output is activated. - -- Set True by use of -gnateg or -gnatd.V. + -- Set True by use of -gnateg or -gnatd.V for GNAT, and -G for GNATBIND. Generate_CodePeer_Messages : Boolean := False; -- GNAT diff --git a/gcc/ada/switch-b.adb b/gcc/ada/switch-b.adb index 2f8831b36f7..fdba595166e 100644 --- a/gcc/ada/switch-b.adb +++ b/gcc/ada/switch-b.adb @@ -294,6 +294,12 @@ package body Switch.B is Debugger_Level := 2; end if; + -- Processing for G switch + + when 'G' => + Ptr := Ptr + 1; + Generate_C_Code := True; + -- Processing for h switch when 'h' => -- 2.30.2