[Ada] GNAT.Sockets: fix Get_Address when AF_INET6 is not defined
authorDmitriy Anisimkov <anisimko@adacore.com>
Mon, 1 Jul 2019 13:34:34 +0000 (13:34 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Mon, 1 Jul 2019 13:34:34 +0000 (13:34 +0000)
2019-07-01  Dmitriy Anisimkov  <anisimko@adacore.com>

gcc/ada/

* libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6
is not defined.

From-SVN: r272856

gcc/ada/ChangeLog
gcc/ada/libgnat/g-sothco.adb

index 82e808bf9a5ac8e60407b1d59c599f6797653ee7..1d353e86328bb901aafcb1d1612d666f6e9f0628 100644 (file)
@@ -1,3 +1,8 @@
+2019-07-01  Dmitriy Anisimkov  <anisimko@adacore.com>
+
+       * libgnat/g-sothco.adb (Get_Address): Fix the case when AF_INET6
+       is not defined.
+
 2019-07-01  Ed Schonberg  <schonberg@adacore.com>
 
        * exp_attr.adb (Expand_Attribute_Reference, case Invalid_Value):
index df82d012259d43f55c9e503fe1fa4e736495e09f..eb15ac2e8429fb38eb4bd1b8a083e31f6efb8462 100644 (file)
@@ -59,14 +59,15 @@ package body GNAT.Sockets.Thin_Common is
    -----------------
 
    function Get_Address (Sin : Sockaddr) return Sock_Addr_Type is
+      use type C.unsigned_short;
       Family : constant C.unsigned_short :=
         (if SOSC.Has_Sockaddr_Len = 0 then Sin.Sin_Family.Short_Family
          else C.unsigned_short (Sin.Sin_Family.Char_Family));
+      AF_INET6_Defined : constant Boolean := SOSC.AF_INET6 > 0;
       Result : Sock_Addr_Type
-        (case Family is
-            when SOSC.AF_INET6 => Family_Inet6,
-            when SOSC.AF_INET  => Family_Inet,
-            when others        => Family_Unspec);
+        (if AF_INET6_Defined and then SOSC.AF_INET6 = Family then Family_Inet6
+         elsif SOSC.AF_INET = Family then Family_Inet
+         else Family_Unspec);
    begin
       Result.Port := Port_Type (Network_To_Short (Sin.Sin_Port));