This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[c-family] Issue a warning on packed record layout with -fdump-ada-spec


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  <ebotcazou@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  <ebotcazou@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 } } */

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]