The packed record layout is not really supported for the time being.

Tested on x86-64/Linux, applied on the mainline.


2018-09-21  Eric Botcazou  <ebotca...@adacore.com>

        * c-ada-spec.c: Include diagnostic.h.
        (dump_ada_declaration) <RECORD_TYPE>: Issue a warning on packed layout.


2018-09-21  Eric Botcazou  <ebotca...@adacore.com>

        * c-c++-common/dump-ada-spec-14.c: New test.

-- 
Eric Botcazou
Index: c-ada-spec.c
===================================================================
--- c-ada-spec.c	(revision 264342)
+++ c-ada-spec.c	(working copy)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.
 #include "c-ada-spec.h"
 #include "fold-const.h"
 #include "c-pragma.h"
+#include "diagnostic.h"
 #include "stringpool.h"
 #include "attribs.h"
 
@@ -2700,6 +2701,16 @@ dump_ada_declaration (pretty_printer *bu
 		return 1;
 	      }
 
+	    /* ??? Packed record layout is not supported.  */
+	    if (TYPE_PACKED (TREE_TYPE (t)))
+	      {
+		warning_at (DECL_SOURCE_LOCATION (t), 0,
+			    "unsupported record layout");
+		pp_string (buffer, "pragma Compile_Time_Warning (True, ");
+		pp_string (buffer, "\"probably incorrect record layout\");");
+		newline_and_indent (buffer, spc);
+	      }
+
 	    if (orig && TYPE_NAME (orig))
 	      pp_string (buffer, "subtype ");
 	    else
/* { dg-do compile } */
/* { dg-options "-fdump-ada-spec" } */

struct __attribute__((packed)) S /* { dg-warning "unsupported record layout" } */
{
  char c;
  int  t;
};

/* { dg-final { cleanup-ada-spec } } */

Reply via email to