Commit 97edd426 by Arnaud Charlet Committed by Pierre-Marie de Rodat

[Ada] Add a gnatbind option to generate C code

2019-07-03  Arnaud Charlet  <charlet@adacore.com>

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
parent 81c10c3f
2019-07-03 Arnaud Charlet <charlet@adacore.com>
* 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 <charlet@adacore.com>
* sem_ch7.adb (Has_Referencer): Do not consider inlined
subprograms when generating C code, which allows us to generate
static inline subprograms.
......
......@@ -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);");
......
......@@ -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
......
......@@ -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
......
......@@ -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' =>
......
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