c-ada-spec.c: Include diagnostic.h.
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 21 Sep 2018 10:11:37 +0000 (10:11 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 21 Sep 2018 10:11:37 +0000 (10:11 +0000)
* c-ada-spec.c: Include diagnostic.h.
(dump_ada_declaration) <RECORD_TYPE>: Issue a warning on packed layout.

From-SVN: r264466

gcc/c-family/ChangeLog
gcc/c-family/c-ada-spec.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/dump-ada-spec-14.c [new file with mode: 0644]

index 8fc773cac2ed8504cd711d1615db35f235520e33..4080bee111dc6d23cf664f2b902afb09ebe0c34e 100644 (file)
@@ -1,3 +1,8 @@
+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-19  Marek Polacek  <polacek@redhat.com>
 
        * c.opt (Wclass-conversion): New.
index 5e0dea4aa9d6b92fa4d522b176fc42ca0006772c..eae741ed6b533aa3ca2e09896f225a4cc785321c 100644 (file)
@@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
 #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 *buffer, tree t, tree type, int spc)
                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
index b0664206895140271ed6f3c397b408e71d0cad55..6f338c2e84c5ca6ebcf3fb160a231edfdbb14ca1 100644 (file)
@@ -1,3 +1,7 @@
+2018-09-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * c-c++-common/dump-ada-spec-14.c: New test.
+
 2018-09-21  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/nested-func-11.c: New test.
diff --git a/gcc/testsuite/c-c++-common/dump-ada-spec-14.c b/gcc/testsuite/c-c++-common/dump-ada-spec-14.c
new file mode 100644 (file)
index 0000000..bfdec61
--- /dev/null
@@ -0,0 +1,10 @@
+/* { 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 } } */