aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c99-flex-array-4.c
diff options
context:
space:
mode:
authorJoseph Myers <jsm@polyomino.org.uk>2002-08-17 15:48:28 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2002-08-17 15:48:28 +0100
commit2984fe64968ad7140e84f8137c877c9e6d25136a (patch)
tree89955359e44fa2311d348937a438303874397fd2 /gcc/testsuite/gcc.dg/c99-flex-array-4.c
parentfded6d781c8e005bc195fc047a7e480073871c35 (diff)
downloadgcc-2984fe64968ad7140e84f8137c877c9e6d25136a.zip
gcc-2984fe64968ad7140e84f8137c877c9e6d25136a.tar.gz
gcc-2984fe64968ad7140e84f8137c877c9e6d25136a.tar.bz2
c-decl.c (flexible_array_type_p): New function.
* c-decl.c (flexible_array_type_p): New function. (grokdeclarator, finish_struct): Use it. * doc/extend.texi: Document constraints on use of structures with flexible array members. testsuite: * gcc.dg/c90-flex-array-1.c, gcc.dg/c99-flex-array-3.c, gcc.dg/c99-flex-array-4.c: New tests. From-SVN: r56411
Diffstat (limited to 'gcc/testsuite/gcc.dg/c99-flex-array-4.c')
-rw-r--r--gcc/testsuite/gcc.dg/c99-flex-array-4.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c99-flex-array-4.c b/gcc/testsuite/gcc.dg/c99-flex-array-4.c
new file mode 100644
index 0000000..ab20cf0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-flex-array-4.c
@@ -0,0 +1,25 @@
+/* Test for flexible array members. Test for agreement of offset and
+ structure size. This is expected to fail, because of a possible
+ defect in the standard. */
+/* Origin: http://gcc.gnu.org/ml/gcc/2002-05/msg02844.html
+ from Tony Finch <dot@dotat.at>, adapted to a testcase by Joseph Myers
+ <jsm28@cam.ac.uk>. See also WG14 reflector messages 9571-3. */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+#include <stddef.h>
+
+struct foo {
+ int a;
+ short b;
+ char pad[];
+};
+
+struct bar {
+ int a;
+ short b;
+ char pad[1024];
+};
+
+char x[(sizeof(struct foo) == offsetof(struct foo, pad)) ? 1 : -1]; /* { dg-bogus "negative" "sizeof != offsetof" { xfail *-*-* } } */
+char y[(offsetof(struct foo, pad) == offsetof(struct bar, pad)) ? 1 : -1];