summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/c99-array-lval-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/c99-array-lval-3.c')
-rw-r--r--gcc/testsuite/gcc.dg/c99-array-lval-3.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/c99-array-lval-3.c b/gcc/testsuite/gcc.dg/c99-array-lval-3.c
new file mode 100644
index 000000000..a12a9600b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-array-lval-3.c
@@ -0,0 +1,24 @@
+/* Test for non-lvalue arrays decaying to pointers: in C99 only.
+ Test various ways of producing non-lvalue arrays. */
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+struct s { char c[1]; };
+struct s a, b, c;
+int d;
+
+void
+bar (void)
+{
+ char *t;
+ (d ? b : c).c[0];
+ (d, b).c[0];
+ (a = b).c[0];
+ t = (d ? b : c).c;
+ t = (d, b).c;
+ t = (a = b).c;
+ (d ? b : c).c + 1;
+ (d, b).c + 1;
+ (a = b).c + 1;
+}