aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorAndrew Pinski <pinskia@physics.uc.edu>2005-11-03 16:15:53 +0000
committerAndrew Pinski <pinskia@gcc.gnu.org>2005-11-03 08:15:53 -0800
commitca0b7d18c1cd76de7015e01ff1414c4314eda7b4 (patch)
tree486ee6dc152e01f26744eebbd7a4694f864135df /gcc/testsuite/gcc.dg
parent031905948adabb18c9a4f1fe9156cbf5aea964b2 (diff)
downloadgcc-ca0b7d18c1cd76de7015e01ff1414c4314eda7b4.zip
gcc-ca0b7d18c1cd76de7015e01ff1414c4314eda7b4.tar.gz
gcc-ca0b7d18c1cd76de7015e01ff1414c4314eda7b4.tar.bz2
re PR middle-end/23155 (Gimplification failed for union cast)
2005-11-03 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/23155 * g++.dg/ext/c99struct1.C: New test. * gcc.dg/union-cast-1.c: New test. * gcc.dg/union-cast-2.c: New test. * gcc.dg/union-cast-3.c: New test. 2005-11-03 Andrew Pinski <pinskia@physics.uc.edu> PR middle-end/23155 * gimplifier.c (gimplify_expr): Create a temporary for lvalue CONSTRUCTOR. From-SVN: r106438
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/union-cast-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/union-cast-2.c15
-rw-r--r--gcc/testsuite/gcc.dg/union-cast-3.c14
3 files changed, 43 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/union-cast-1.c b/gcc/testsuite/gcc.dg/union-cast-1.c
new file mode 100644
index 0000000..1d7f4d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/union-cast-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+/* A combine of two extensions to C89 are used here.
+ First casts to unions is used.
+ Second subscripting non lvalue arrays, this is in C99. */
+
+union vx {short f[8]; int v;};
+int vec;
+
+void
+foo5 (int vec)
+{
+ ((union vx) vec).f[5] = 1;
+}
diff --git a/gcc/testsuite/gcc.dg/union-cast-2.c b/gcc/testsuite/gcc.dg/union-cast-2.c
new file mode 100644
index 0000000..9aac5ca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/union-cast-2.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c89 -pedantic-errors" } */
+/* PR 23155
+ We should get two error messages, one about union cast
+ and the other about array access for non lvalues. */
+
+
+union vx {short f[8]; int v;};
+int vec;
+
+void
+foo5 (int vec)
+{
+ ((union vx) vec).f[5] = 1; /* { dg-error "(forbids subscripting)|(forbids casts to union type)" } */
+}
diff --git a/gcc/testsuite/gcc.dg/union-cast-3.c b/gcc/testsuite/gcc.dg/union-cast-3.c
new file mode 100644
index 0000000..5f9b9f8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/union-cast-3.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+/* PR 23155
+ We should get one error messag, one about union cast. */
+
+
+union vx {short f[8]; int v;};
+int vec;
+
+void
+foo5 (int vec)
+{
+ ((union vx) vec).f[5] = 1; /* { dg-error "forbids casts to union type" } */
+}