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

Message ID 3489529.Ez6E6liNH7@polaris
State New
Headers show
Series
  • [c-family] Issue a warning on packed record layout with -fdump-ada-spec
Related show

Commit Message

Eric Botcazou Sept. 21, 2018, 10:11 a.m.
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

Patch

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