diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-23 22:36:54 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-02-23 22:36:54 +0000 |
commit | 88a3ea34080ad3087a8191fbf479543153175d59 (patch) | |
tree | 34eaec34d3588e09f9a77abba776266f124dc823 /gcc/testsuite/gcc.dg/Wattributes-8.c | |
parent | 25e15aaed275cdfef34b3ee6eb3cb4b43a48d44f (diff) | |
parent | e65055a558093bd4fc0b1b0024b7814cc187b8e8 (diff) | |
download | gccgo.tar.gz |
Merge from trunk revision 257954.gccgo
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gccgo@257955 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/gcc.dg/Wattributes-8.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/Wattributes-8.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/Wattributes-8.c b/gcc/testsuite/gcc.dg/Wattributes-8.c new file mode 100644 index 00000000000..a4b4c00c08f --- /dev/null +++ b/gcc/testsuite/gcc.dg/Wattributes-8.c @@ -0,0 +1,38 @@ +/* PR middle-end/84108 - incorrect -Wattributes warning for packed/aligned + conflict on struct members + { dg-do compile } + { dg-options "-Wall -Wattributes" } */ + +#define ATTR(list) __attribute__ (list) +#define ASSERT(e) _Static_assert (e, #e) + +/* GCC is inconsistent in how it treats attribute aligned between + variable and member declarations. Attribute aligned alone is + sufficient to reduce a variable's alignment requirement but + the attribute must be paired with packed to have the same + effect on a member. Worse, declaring a variable both aligned + and packed emits a warning. */ + +/* Avoid exercising this since emitting a warning for these given + the requirement for members seems like a misfeature: + int a ATTR ((packed, aligned (2))); // -Wattributes + int b ATTR ((aligned (2), packed)); // -Wattributes + ASSERT (_Alignof (a) == 2); + ASSERT (_Alignof (b) == 2); */ + +int c ATTR ((aligned (2))); // okay (reduces alignment) +ASSERT (_Alignof (c) == 2); + +struct { + int a ATTR ((packed, aligned (2))); /* { dg-bogus "\\\[-Wattributes" } */ + int b ATTR ((aligned (2), packed)); /* { dg-bogus "\\\[-Wattributes" } */ + + /* Avoid exercising this since the attribute has no effect yet + there is no warning. + int c ATTR ((aligned (2))); // missing warning? */ +} s; + +ASSERT (_Alignof (s.a) == 2); +ASSERT (_Alignof (s.b) == 2); + +/* ASSERT (_Alignof (s.c) == 4); */ |