aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2006-01-17 10:57:56 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2006-01-17 10:57:56 +0100
commit3aa2ddb8859364abdbe391467e91c0741a7fba3e (patch)
tree199ee3e668600a1058b2f24948647c8931113c50 /gcc/testsuite/gcc.dg
parent474eccc60315960b14fb0af4b7da9c6795ac4f0e (diff)
downloadgcc-3aa2ddb8859364abdbe391467e91c0741a7fba3e.zip
gcc-3aa2ddb8859364abdbe391467e91c0741a7fba3e.tar.gz
gcc-3aa2ddb8859364abdbe391467e91c0741a7fba3e.tar.bz2
re PR c/25682 (ICE when using old sytle offsetof (with non zero start) as array size)
PR c/25682 * c-typeck.c (build_unary_op): Fold offsetof-like expressions even when the pointer is not NULL. cp/ * decl.c (compute_array_index_type): After issuing not an integral constant-expression error, set size to 1 to avoid ICEs later on. testsuite/ * gcc.dg/pr25682.c: New test. * g++.dg/parse/array-size2.C: New test. From-SVN: r109812
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/pr25682.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr25682.c b/gcc/testsuite/gcc.dg/pr25682.c
new file mode 100644
index 0000000..3a1d7c2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr25682.c
@@ -0,0 +1,27 @@
+/* PR c/25682 */
+/* { dg-do compile } */
+/* Test whether we don't ICE on questionable constructs where offsetof
+ should have been used instead. */
+
+struct S
+{
+ char a[4];
+ int b;
+};
+
+char c[(char *) &((struct S *) 0)->b - (char *) 0];
+char d[(__SIZE_TYPE__) &((struct S *) 8)->b];
+char e[sizeof (c) == __builtin_offsetof (struct S, b) ? 1 : -1];
+char f[sizeof (d) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
+
+extern void bar (char *, char *);
+
+void
+foo (void)
+{
+ char g[(char *) &((struct S *) 0)->b - (char *) 0];
+ char h[(__SIZE_TYPE__) &((struct S *) 8)->b];
+ char i[sizeof (g) == __builtin_offsetof (struct S, b) ? 1 : -1];
+ char j[sizeof (h) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1];
+ bar (g, h);
+}