public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Ada] Generate minimally correct C/C++ binding for stddef.h
@ 2018-02-28 14:31 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2018-02-28 14:31 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 366 bytes --]

This was broken when the default was changed to C11/C++11.

Tested on x86_64-suse-linux, applied on the mainline.


2018-02-28  Eric Botcazou  <ebotcazou@adacore.com>

ada/
	* libgnat/i-cexten.ads (Float_128): New type.

c-family/
	* c-ada-spec.c (dump_ada_node) <NULLPTR_TYPE>: New case.
	<REAL_TYPE>: Deal specifically with _Float128/__float128.

-- 
Eric Botcazou

[-- Attachment #2: p4.diff --]
[-- Type: text/x-patch, Size: 2294 bytes --]

Index: ada/libgnat/i-cexten.ads
===================================================================
--- ada/libgnat/i-cexten.ads	(revision 257983)
+++ ada/libgnat/i-cexten.ads	(working copy)
@@ -72,6 +72,15 @@ package Interfaces.C.Extensions is
    pragma Convention (C_Pass_By_Copy, Signed_128);
    for Signed_128'Alignment use unsigned_long_long'Alignment * 2;
 
+   --  128-bit floating-point type available on x86:
+   --  typedef long_double float_128 __attribute__ ((mode (TF)));
+
+   type Float_128 is record
+      low, high : unsigned_long_long;
+   end record;
+   pragma Convention (C_Pass_By_Copy, Float_128);
+   for Float_128'Alignment use unsigned_long_long'Alignment * 2;
+
    --  Types for bitfields
 
    type Unsigned_1 is mod 2 ** 1;
Index: c-family/c-ada-spec.c
===================================================================
--- c-family/c-ada-spec.c	(revision 258067)
+++ c-family/c-ada-spec.c	(working copy)
@@ -2126,6 +2126,7 @@ dump_ada_node (pretty_printer *buffer, tree node,
       pp_string (buffer, "--- unexpected node: TREE_VEC");
       return 0;
 
+    case NULLPTR_TYPE:
     case VOID_TYPE:
       if (package_prefix)
 	{
@@ -2151,8 +2152,20 @@ dump_ada_node (pretty_printer *buffer, tree node,
 	dump_ada_enum_type (buffer, node, type, spc, true);
       break;
 
+    case REAL_TYPE:
+      if (TYPE_NAME (node)
+	  && TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
+	  && IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))) [0] == '_'
+	  && (id_equal (DECL_NAME (TYPE_NAME (node)), "_Float128")
+	      || id_equal (DECL_NAME (TYPE_NAME (node)), "__float128")))
+	{
+	  append_withs ("Interfaces.C.Extensions", false);
+	  pp_string (buffer, "Extensions.Float_128");
+	  break;
+	}
+      /* fallthrough */
+
     case INTEGER_TYPE:
-    case REAL_TYPE:
     case FIXED_POINT_TYPE:
     case BOOLEAN_TYPE:
       if (TYPE_NAME (node))
@@ -2233,9 +2246,8 @@ dump_ada_node (pretty_printer *buffer, tree node,
 	    {
 	      if (TREE_CODE (node) == POINTER_TYPE
 		  && TREE_CODE (TREE_TYPE (node)) == INTEGER_TYPE
-		  && !strcmp
-			(IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME
-			  (TREE_TYPE (node)))), "char"))
+		  && id_equal (DECL_NAME (TYPE_NAME (TREE_TYPE (node))),
+			       "char"))
 		{
 		  if (!name_only)
 		    pp_string (buffer, "new ");

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-02-28 14:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-28 14:31 [Ada] Generate minimally correct C/C++ binding for stddef.h Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).