From 518196cb3fce647789ff4c9f4679bb7087030158 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 21 Sep 2018 10:11:37 +0000 Subject: [PATCH] c-ada-spec.c: Include diagnostic.h. * c-ada-spec.c: Include diagnostic.h. (dump_ada_declaration) : Issue a warning on packed layout. From-SVN: r264466 --- gcc/c-family/ChangeLog | 5 +++++ gcc/c-family/c-ada-spec.c | 11 +++++++++++ gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/c-c++-common/dump-ada-spec-14.c | 10 ++++++++++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/dump-ada-spec-14.c diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 8fc773cac2e..4080bee111d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,3 +1,8 @@ +2018-09-21 Eric Botcazou + + * c-ada-spec.c: Include diagnostic.h. + (dump_ada_declaration) : Issue a warning on packed layout. + 2018-09-19 Marek Polacek * c.opt (Wclass-conversion): New. diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c index 5e0dea4aa9d..eae741ed6b5 100644 --- a/gcc/c-family/c-ada-spec.c +++ b/gcc/c-family/c-ada-spec.c @@ -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 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b0664206895..6f338c2e84c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-09-21 Eric Botcazou + + * c-c++-common/dump-ada-spec-14.c: New test. + 2018-09-21 Eric Botcazou * 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 index 00000000000..bfdec6181b5 --- /dev/null +++ b/gcc/testsuite/c-c++-common/dump-ada-spec-14.c @@ -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 } } */ -- 2.30.2