bindgen.adb (Gen_Output_File_C): When switch -a was specified...
authorVincent Celier <celier@adacore.com>
Thu, 7 Jul 2005 09:41:44 +0000 (11:41 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 7 Jul 2005 09:41:44 +0000 (11:41 +0200)
2005-07-07  Vincent Celier  <celier@adacore.com>

* bindgen.adb (Gen_Output_File_C): When switch -a was specified, put
the destructor/constructor attributes for <lib>final/<lib>init.

* gnatbind.adb (Gnatbind): Allow -a to be used in conjunction with -C

From-SVN: r101692

gcc/ada/bindgen.adb
gcc/ada/gnatbind.adb

index e37a386a9be2c3903b5e2ec1ede3093a093d2299..bd3867487c12301c0d732d4047e6bbae0e9ec31c 100644 (file)
@@ -2522,8 +2522,18 @@ package body Bindgen is
       WBI ("  (int, int, char, char, char, char,");
       WBI ("   const char *, const char *,");
       WBI ("   int, int, int, int, int);");
-      WBI ("extern void " & Ada_Final_Name.all & " (void);");
-      WBI ("extern void " & Ada_Init_Name.all & " (void);");
+
+      if Use_Pragma_Linker_Constructor then
+         WBI ("extern void " & Ada_Final_Name.all &
+              " (void) __attribute__((destructor));");
+         WBI ("extern void " & Ada_Init_Name.all &
+              " (void) __attribute__((constructor));");
+
+      else
+         WBI ("extern void " & Ada_Final_Name.all & " (void);");
+         WBI ("extern void " & Ada_Init_Name.all & " (void);");
+      end if;
+
       WBI ("extern void system__standard_library__adafinal (void);");
 
       if not No_Main_Subprogram then
index cbd3ceabf6edd853e645ee3725f98c09d8b7fc00..270d3342810e04eeb5e67d8d8da182f0bfab6e1f 100644 (file)
@@ -413,9 +413,6 @@ begin
       if Bind_Main_Program then
          Fail ("switch -a must be used in conjunction with -n or -Lxxx");
 
-      elsif not Ada_Bind_File then
-         Fail ("switch -a cannot be used when C code is generated");
-
       elsif not Gnatbind_Supports_Auto_Init then
          Fail ("automatic initialisation of elaboration " &
                "not supported on this platform");