aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/bconstp-2.c27
-rw-r--r--gcc/testsuite/gcc.dg/bconstp-3.c27
-rw-r--r--gcc/testsuite/gcc.dg/bconstp-4.c10
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-1.c10
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-10.c28
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-11.c27
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-2.c8
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-3.c14
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-6.c53
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-7.c35
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-8.c27
-rw-r--r--gcc/testsuite/gcc.dg/c90-const-expr-9.c26
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-10.c28
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-11.c46
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-12.c23
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-13.c15
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-2.c6
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-3.c14
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-6.c62
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-7.c43
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-8.c27
-rw-r--r--gcc/testsuite/gcc.dg/c99-const-expr-9.c26
-rw-r--r--gcc/testsuite/gcc.dg/c99-static-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/compare10.c16
-rw-r--r--gcc/testsuite/gcc.dg/gnu89-const-expr-1.c47
-rw-r--r--gcc/testsuite/gcc.dg/gnu89-const-expr-2.c23
-rw-r--r--gcc/testsuite/gcc.dg/gnu99-const-expr-1.c47
-rw-r--r--gcc/testsuite/gcc.dg/gnu99-const-expr-2.c23
-rw-r--r--gcc/testsuite/gcc.dg/gnu99-const-expr-3.c32
-rw-r--r--gcc/testsuite/gcc.dg/overflow-warn-1.c9
-rw-r--r--gcc/testsuite/gcc.dg/overflow-warn-2.c31
-rw-r--r--gcc/testsuite/gcc.dg/overflow-warn-3.c17
-rw-r--r--gcc/testsuite/gcc.dg/overflow-warn-4.c17
-rw-r--r--gcc/testsuite/gcc.dg/pr14649-1.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr19984.c2
-rw-r--r--gcc/testsuite/gcc.dg/pr25682.c8
-rw-r--r--gcc/testsuite/gcc.dg/real-const-1.c3
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr32230.c2
-rw-r--r--gcc/testsuite/gcc.dg/vla-12.c50
-rw-r--r--gcc/testsuite/gcc.dg/vla-13.c99
-rw-r--r--gcc/testsuite/gcc.dg/vla-14.c33
-rw-r--r--gcc/testsuite/gcc.dg/vla-15.c27
-rw-r--r--gcc/testsuite/gcc.dg/vla-16.c70
43 files changed, 1076 insertions, 66 deletions
diff --git a/gcc/testsuite/gcc.dg/bconstp-2.c b/gcc/testsuite/gcc.dg/bconstp-2.c
new file mode 100644
index 0000000..5b5ff8b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bconstp-2.c
@@ -0,0 +1,27 @@
+/* As bconstp-1.c, but with the __builtin_constant_p calls
+ parenthesized. */
+/* { dg-do compile } */
+
+/* This test checks that builtin_constant_p can be used safely in
+ initializers for static data. The macro X() defined below should
+ be an acceptable initializer expression no matter how complex its
+ argument is. */
+
+extern int a;
+extern int b;
+
+extern int foo(void);
+extern int bar(void);
+
+#define X(exp) ((__builtin_constant_p(exp)) ? (exp) : -1)
+
+const short tests[] = {
+ X(0),
+ X(a),
+ X(0 && a),
+ X(a && b),
+ X(foo()),
+ X(0 && foo()),
+ X(a && foo()),
+ X(foo() && bar())
+};
diff --git a/gcc/testsuite/gcc.dg/bconstp-3.c b/gcc/testsuite/gcc.dg/bconstp-3.c
new file mode 100644
index 0000000..9e3d10f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bconstp-3.c
@@ -0,0 +1,27 @@
+/* As bconstp-1.c, but with the __builtin_constant_p calls inside
+ __builtin_choose_expr. */
+/* { dg-do compile } */
+
+/* This test checks that builtin_constant_p can be used safely in
+ initializers for static data. The macro X() defined below should
+ be an acceptable initializer expression no matter how complex its
+ argument is. */
+
+extern int a;
+extern int b;
+
+extern int foo(void);
+extern int bar(void);
+
+#define X(exp) (__builtin_choose_expr(1, __builtin_constant_p(exp), 1) ? (exp) : -1)
+
+const short tests[] = {
+ X(0),
+ X(a),
+ X(0 && a),
+ X(a && b),
+ X(foo()),
+ X(0 && foo()),
+ X(a && foo()),
+ X(foo() && bar())
+};
diff --git a/gcc/testsuite/gcc.dg/bconstp-4.c b/gcc/testsuite/gcc.dg/bconstp-4.c
new file mode 100644
index 0000000..bb8aef1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bconstp-4.c
@@ -0,0 +1,10 @@
+/* Test that a condition is not counted as a call to
+ __builtin_constant_p if that call is itself inside a conditional
+ expression with __builtin_constant_p condition. */
+/* { dg-do compile } */
+
+extern int foo(void);
+
+#define X(exp) (__builtin_choose_expr(1, __builtin_constant_p(exp), 1) ? (exp) : -1)
+
+const int x = ((__builtin_constant_p(1) ? __builtin_constant_p (0 && foo()) : 0) ? (0 && foo()) : -1); /* { dg-error "initializer element is not a constant expression" } */
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-1.c b/gcc/testsuite/gcc.dg/c90-const-expr-1.c
index 96d19ee..e4c27ac 100644
--- a/gcc/testsuite/gcc.dg/c90-const-expr-1.c
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-1.c
@@ -15,9 +15,9 @@ void
foo (void)
{
int i;
- static int j = (1 ? 0 : (i = 2)); /* { dg-error "initial" "assignment" { xfail *-*-* } } */
- static int k = (1 ? 0 : ++i); /* { dg-error "initial" "increment" { xfail *-*-* } } */
- static int l = (1 ? 0 : --i); /* { dg-error "initial" "decrement" { xfail *-*-* } } */
- static int m = (1 ? 0 : bar ()); /* { dg-error "initial" "function call" { xfail *-*-* } } */
- static int n = (1 ? 0 : (2, 3)); /* { dg-error "initial" "comma" { xfail *-*-* } } */
+ static int j = (1 ? 0 : (i = 2)); /* { dg-error "initial" "assignment" } */
+ static int k = (1 ? 0 : ++i); /* { dg-error "initial" "increment" } */
+ static int l = (1 ? 0 : --i); /* { dg-error "initial" "decrement" } */
+ static int m = (1 ? 0 : bar ()); /* { dg-error "initial" "function call" } */
+ static int n = (1 ? 0 : (2, 3)); /* { dg-error "initial" "comma" } */
}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-10.c b/gcc/testsuite/gcc.dg/c90-const-expr-10.c
new file mode 100644
index 0000000..6159390
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-10.c
@@ -0,0 +1,28 @@
+/* Test for constant expressions: invalid null pointer constants in
+ various contexts (make sure NOPs are not inappropriately
+ stripped). */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast" } */
+void *
+f (void)
+{
+ void *r;
+ r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+ return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+}
+void g (void *); /* { dg-message "but argument is of type" } */
+void
+h (void)
+{
+ g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
+}
+void g2 (int, void *); /* { dg-message "but argument is of type" } */
+void
+h2 (void)
+{
+ g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-11.c b/gcc/testsuite/gcc.dg/c90-const-expr-11.c
new file mode 100644
index 0000000..cfda93e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-11.c
@@ -0,0 +1,27 @@
+/* Test for constant expressions: C90 aggregate initializers requiring
+ constant expressions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors -O2" } */
+
+#include <float.h>
+#include <limits.h>
+
+double atan(double);
+
+struct s { double d; };
+struct t { int i; };
+
+void
+f (void)
+{
+ /* As in PR 14649 for static initializers. */
+ struct s a = { atan (1.0) }; /* { dg-error "is not a constant expression|near initialization" } */
+ /* Overflow. */
+ struct t b = { INT_MAX + 1 }; /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
+ struct t c = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 23 } */
+ /* Bad operator outside sizeof. */
+ struct s d = { 1 ? 1.0 : atan (a.d) }; /* { dg-error "is not a constant expression|near initialization" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-2.c b/gcc/testsuite/gcc.dg/c90-const-expr-2.c
index cad5bc8..662d8e7 100644
--- a/gcc/testsuite/gcc.dg/c90-const-expr-2.c
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-2.c
@@ -34,10 +34,10 @@ foo (void)
{
ASSERT_NPC (0);
ASSERT_NPC ((void *)0);
- ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NOT_NPC ((void *)(0, ZERO)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
- ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
/* This last one is a null pointer constant in C99 only. */
- ASSERT_NOT_NPC ((void *)(1 ? 0 : (0, 0))); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((void *)(1 ? ZERO : (0, ZERO))); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-3.c b/gcc/testsuite/gcc.dg/c90-const-expr-3.c
index 0fda68e..46a0227 100644
--- a/gcc/testsuite/gcc.dg/c90-const-expr-3.c
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-3.c
@@ -28,19 +28,19 @@ foo (void)
ASSERT_NPC (0);
ASSERT_NOT_NPC (ZERO);
ASSERT_NPC (0 + 0);
- ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC (+0);
- ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC (-0);
- ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC ((char) 0);
ASSERT_NOT_NPC ((char) ZERO);
ASSERT_NPC ((int) 0);
ASSERT_NOT_NPC ((int) ZERO);
ASSERT_NPC ((int) 0.0);
ASSERT_NOT_NPC ((int) DZERO);
- ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-6.c b/gcc/testsuite/gcc.dg/c90-const-expr-6.c
new file mode 100644
index 0000000..50de3a9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-6.c
@@ -0,0 +1,53 @@
+/* Test for constant expressions: operands and casts not permitted in
+ integer constant expressions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+/* PR 29116. */
+int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
+
+/* PR 31871. */
+extern int c[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
+
+/* Implicit conversions from floating-point constants are not OK,
+ although explicit ones are. */
+extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab|can't be evaluated" } */
+
+extern int c2[(int)1.0 ? 1 : 0];
+
+extern int c3[1.0 && 1]; /* { dg-error "variab|can't be evaluated" } */
+
+extern int c4[(int)1.0 && 1];
+
+extern int c5[1.0 || 1]; /* { dg-error "variab|can't be evaluated" } */
+
+extern int c6[(int)1.0 || 1];
+
+/* Similar with various other cases where integer constant expressions
+ are required. */
+
+struct s {
+ int a : (n * 0 + 1); /* { dg-error "constant" } */
+};
+
+enum e {
+ E = (1 + ((__PTRDIFF_TYPE__) (void *) 0)), /* { dg-error "constant" } */
+ E2 = 0
+};
+
+enum f {
+ F = (1 ? 1 : n), /* { dg-error "constant" } */
+ F2 = 0
+};
+
+void
+f (int a)
+{
+ int v[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
+ switch (a)
+ {
+ case (n * 0 + 1): /* { dg-error "constant" } */
+ ;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-7.c b/gcc/testsuite/gcc.dg/c90-const-expr-7.c
new file mode 100644
index 0000000..30aeba0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-7.c
@@ -0,0 +1,35 @@
+/* Test for constant expressions: overflow and constant expressions;
+ see also overflow-warn-*.c for some other cases. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+#include <float.h>
+
+int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 9 } */
+int b = (int) DBL_MAX; /* { dg-error "overflow" "" } */
+unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
+unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
+
+int e = 0 << 1000; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 16 } */
+int f = 0 << -1; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 18 } */
+int g = 0 >> 1000; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 20 } */
+int h = 0 >> -1; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 22 } */
+
+int b1 = (0 ? (int) DBL_MAX : 0);
+unsigned int d1 = (0 ? (unsigned int)-1.0 : 0);
+int e1 = (0 ? 0 << 1000 : 0);
+int f1 = (0 ? 0 << -1 : 0);
+int g1 = (0 ? 0 >> 1000 : 0);
+int h1 = (0 ? 0 >> -1: 0);
+
+int i = -1 << 0;
+
+int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 34 } */
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-8.c b/gcc/testsuite/gcc.dg/c90-const-expr-8.c
new file mode 100644
index 0000000..966044c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-8.c
@@ -0,0 +1,27 @@
+/* Test for constant expressions: overflow and constant expressions
+ with -fwrapv: overflows still count as such for the purposes of
+ constant expressions even when they have defined values at
+ runtime. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors -fwrapv" } */
+
+#include <limits.h>
+
+enum e {
+ E0 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
+ E1 = 0 * (INT_MIN / -1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 14 } */
+ E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 16 } */
+ E3 = 0 * (INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 18 } */
+ E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 20 } */
+ E5 = 0 * -INT_MIN, /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 22 } */
+ E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "not an integer constant" "constant" { target *-*-* } 24 } */
+ E7 = INT_MIN % -1 /* Not an overflow. */
+};
diff --git a/gcc/testsuite/gcc.dg/c90-const-expr-9.c b/gcc/testsuite/gcc.dg/c90-const-expr-9.c
new file mode 100644
index 0000000..d9ab375
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c90-const-expr-9.c
@@ -0,0 +1,26 @@
+/* Test for constant expressions: __builtin_offsetof allowed in
+ integer constant expressions but not traditional offsetof
+ expansion. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
+
+struct s {
+ int a;
+};
+
+struct t {
+ struct s a;
+ int b[2];
+};
+
+#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__) &((TYPE *)0)->MEMBER)
+
+enum e {
+ E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */
+ E2 = old_offsetof (struct t, a.a), /* { dg-error "constant" } */
+ E3 = old_offsetof (struct t, b[1]), /* { dg-error "constant" } */
+ E4 = __builtin_offsetof (struct s, a),
+ E5 = __builtin_offsetof (struct t, a.a),
+ E6 = __builtin_offsetof (struct t, b[1])
+};
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-10.c b/gcc/testsuite/gcc.dg/c99-const-expr-10.c
new file mode 100644
index 0000000..8e5a104
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-10.c
@@ -0,0 +1,28 @@
+/* Test for constant expressions: invalid null pointer constants in
+ various contexts (make sure NOPs are not inappropriately
+ stripped). */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+void *p = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+struct s { void *a; } q = { (__SIZE_TYPE__)(void *)0 }; /* { dg-error "without a cast" } */
+void *
+f (void)
+{
+ void *r;
+ r = (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+ return (__SIZE_TYPE__)(void *)0; /* { dg-error "without a cast" } */
+}
+void g (void *); /* { dg-message "but argument is of type" } */
+void
+h (void)
+{
+ g ((__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
+}
+void g2 (int, void *); /* { dg-message "but argument is of type" } */
+void
+h2 (void)
+{
+ g2 (0, (__SIZE_TYPE__)(void *)0); /* { dg-error "without a cast" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-11.c b/gcc/testsuite/gcc.dg/c99-const-expr-11.c
new file mode 100644
index 0000000..21d9c5f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-11.c
@@ -0,0 +1,46 @@
+/* Test for constant expressions: cases involving VLAs. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+/* It appears address constants may contain casts to variably modified
+ types. Whether they should be permitted was discussed in
+ <http://groups.google.com/group/comp.std.c/msg/923eee5ab690fd98>
+ <LV7g2Vy3ARF$Ew9Q@romana.davros.org>; since static pointers to VLAs
+ are definitely permitted within functions and may be initialized
+ and such initialization involves implicit conversion to a variably
+ modified type, allowing explicit casts seems appropriate. Thus,
+ GCC allows them as long as the "evaluated" size expressions do not
+ contain the various operators not permitted to be evaluated in a
+ constant expression, and as long as the result is genuinely
+ constant (meaning that pointer arithmetic using the size of the VLA
+ is generally not permitted). */
+
+static int sa[100];
+
+volatile int nv;
+
+int
+f (int m, int n)
+{
+ static int (*a1)[n] = &sa;
+ static int (*a2)[n] = (int (*)[n])sa;
+ static int (*a3)[n] = (int (*)[(int){n}])sa;
+ static int (*a4)[n] = (int (*)[(int){m++}])sa; /* { dg-error "constant" } */
+ static int (*a5)[n] = (int (*)[(int){++m}])sa; /* { dg-error "constant" } */
+ static int (*a6)[n] = (int (*)[(int){m--}])sa; /* { dg-error "constant" } */
+ static int (*a7)[n] = (int (*)[(int){--m}])sa; /* { dg-error "constant" } */
+ static int (*a8)[n] = (int (*)[(m=n)])sa; /* { dg-error "constant" } */
+ static int (*a9)[n] = (int (*)[(m+=n)])sa; /* { dg-error "constant" } */
+ static int (*a10)[n] = (int (*)[f(m,n)])sa; /* { dg-error "constant" } */
+ static int (*a11)[n] = (int (*)[(m,n)])sa; /* { dg-error "constant" } */
+ static int (*a12)[n] = (int (*)[sizeof(int[n])])sa;
+ static int (*a13)[n] = (int (*)[sizeof(int[m++])])sa; /* { dg-error "constant" } */
+ static int (*a14)[n] = (int (*)[sizeof(*a1)])sa;
+ static int (*a15)[n] = (int (*)[sizeof(*(int (*)[n])sa)])sa;
+ static int (*a16)[n] = (int (*)[sizeof(*(int (*)[m++])sa)])sa; /* { dg-error "constant" } */
+ static int (*a17)[n] = (int (*)[nv])sa;
+ typedef int (*vmt)[m++];
+ static int (*a18)[n] = (vmt)sa;
+ return n;
+}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-12.c b/gcc/testsuite/gcc.dg/c99-const-expr-12.c
new file mode 100644
index 0000000..396cea5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-12.c
@@ -0,0 +1,23 @@
+/* Test for constant expressions: VLA size constraints. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+void
+f (int m)
+{
+ /* An array size that is a constant expression, not just an integer
+ constant expression, must be checked for being positive, but only
+ an integer constant expression makes it not a VLA (which affects
+ certain compatibility checks, in particular). */
+ int a1[0]; /* { dg-error "zero" } */
+ int a2[-1]; /* { dg-error "negative" } */
+ int a3[(int)(double)0.0]; /* { dg-error "zero" } */
+ int a4[(int)-1.0]; /* { dg-error "negative" } */
+ int a5[(int)+1.0];
+ int a6[(int)+2.0];
+ void *p = (m ? &a5 : &a6);
+ int a7[(int)1.0];
+ int a8[(int)2.0];
+ void *q = (m ? &a7 : &a8); /* { dg-error "pointer type mismatch in conditional expression" } */
+}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-13.c b/gcc/testsuite/gcc.dg/c99-const-expr-13.c
new file mode 100644
index 0000000..0ee525b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-13.c
@@ -0,0 +1,15 @@
+/* Test for constant expressions: VLA size constraints with
+ -frounding-math. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors -frounding-math" } */
+
+void
+f (void)
+{
+ /* With -frounding-math, presume that floating-point expressions
+ that may depend on the rounding mode do not count as arithmetic
+ constant expressions, and so arrays involving such expressions in
+ their sizes do not have the size checked for being negative. */
+ int a1[(int)(-5.0/3.0)];
+}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-2.c b/gcc/testsuite/gcc.dg/c99-const-expr-2.c
index 555a58c..8e5a600 100644
--- a/gcc/testsuite/gcc.dg/c99-const-expr-2.c
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-2.c
@@ -34,10 +34,10 @@ foo (void)
{
ASSERT_NPC (0);
ASSERT_NPC ((void *)0);
- ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((void *)(void *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((void *)(char *)0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NOT_NPC ((void *)(0, ZERO)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
- ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((void *)(&"Foobar"[0] - &"Foobar"[0])); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
/* This last one is a null pointer constant in C99 only. */
ASSERT_NPC ((void *)(1 ? 0 : (0, 0)));
}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-3.c b/gcc/testsuite/gcc.dg/c99-const-expr-3.c
index f230603..9b036a3 100644
--- a/gcc/testsuite/gcc.dg/c99-const-expr-3.c
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-3.c
@@ -27,19 +27,19 @@ foo (void)
ASSERT_NPC (0);
ASSERT_NOT_NPC (ZERO);
ASSERT_NPC (0 + 0);
- ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (ZERO + 0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC (ZERO + ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC (+0);
- ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (+ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC (-0);
- ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC (-ZERO); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
ASSERT_NPC ((char) 0);
ASSERT_NOT_NPC ((char) ZERO);
ASSERT_NPC ((int) 0);
ASSERT_NOT_NPC ((int) ZERO);
ASSERT_NPC ((int) 0.0);
ASSERT_NOT_NPC ((int) DZERO);
- ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
- ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" { xfail *-*-* } } */
+ ASSERT_NOT_NPC ((int) +0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((int) (0.0+0.0)); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
+ ASSERT_NOT_NPC ((int) (double)0.0); /* { dg-bogus "incompatible" "bogus null pointer constant" } */
}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-6.c b/gcc/testsuite/gcc.dg/c99-const-expr-6.c
new file mode 100644
index 0000000..1a31ddc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-6.c
@@ -0,0 +1,62 @@
+/* Test for constant expressions: operands and casts not permitted in
+ integer constant expressions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+/* PR 29116. */
+int n = 0, p[n * 0 + 1]; /* { dg-error "variabl" } */
+
+/* PR 31871. */
+extern int c[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab" } */
+
+/* Implicit conversions from floating-point constants are not OK,
+ although explicit ones are. */
+extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab" } */
+
+extern int c2[(int)1.0 ? 1 : 0];
+
+extern int c3[1.0 && 1]; /* { dg-error "variab" } */
+
+extern int c4[(int)1.0 && 1];
+
+extern int c5[1.0 || 1]; /* { dg-error "variab" } */
+
+extern int c6[(int)1.0 || 1];
+
+/* Similar with various other cases where integer constant expressions
+ are required. */
+
+struct s {
+ int a : (n * 0 + 1); /* { dg-error "constant" } */
+};
+
+enum e {
+ E = (1 + ((__PTRDIFF_TYPE__) (void *) 0)), /* { dg-error "constant" } */
+ E2 = 0
+};
+
+enum f {
+ F = (1 ? 1 : n), /* { dg-error "constant" } */
+ F2 = 0
+};
+
+/* Presume that a compound literal, being a reference to an anonymous
+ variable, is not allowed in an integer constant expression
+ regardless of what initializers it contains. */
+enum g {
+ G = (1 ? 1 : (int){0}), /* { dg-error "constant" } */
+ G2 = 0
+};
+
+int v[2] = { [(n * 0 + 1)] = 1 }; /* { dg-error "constant|near initialization" } */
+
+void
+f (int a)
+{
+ switch (a)
+ {
+ case (n * 0 + 1): /* { dg-error "constant" } */
+ ;
+ }
+}
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-7.c b/gcc/testsuite/gcc.dg/c99-const-expr-7.c
new file mode 100644
index 0000000..b872077
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-7.c
@@ -0,0 +1,43 @@
+/* Test for constant expressions: overflow and constant expressions;
+ see also overflow-warn-*.c for some other cases. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+#include <float.h>
+#include <limits.h>
+
+int a = DBL_MAX; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 10 } */
+int b = (int) DBL_MAX; /* { dg-error "overflow" "" } */
+unsigned int c = -1.0; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 13 } */
+unsigned int d = (unsigned)-1.0; /* { dg-error "overflow" } */
+
+int e = 0 << 1000; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 17 } */
+int f = 0 << -1; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 19 } */
+int g = 0 >> 1000; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 21 } */
+int h = 0 >> -1; /* { dg-warning "shift count" } */
+/* { dg-error "constant" "constant" { target *-*-* } 23 } */
+
+int b1 = (0 ? (int) DBL_MAX : 0);
+unsigned int d1 = (0 ? (unsigned int)-1.0 : 0);
+int e1 = (0 ? 0 << 1000 : 0);
+int f1 = (0 ? 0 << -1 : 0);
+int g1 = (0 ? 0 >> 1000 : 0);
+int h1 = (0 ? 0 >> -1: 0);
+
+/* Allowed for now, but actually undefined behavior in C99. */
+int i = -1 << 0;
+
+int j[1] = { DBL_MAX }; /* { dg-warning "overflow in implicit constant conversion" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 36 } */
+
+int array[2] = { [0 * (INT_MAX + 1)] = 0 }; /* { dg-warning "integer overflow in expression" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 39 } */
+
+_Bool k = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 42 } */
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-8.c b/gcc/testsuite/gcc.dg/c99-const-expr-8.c
new file mode 100644
index 0000000..e84fa7b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-8.c
@@ -0,0 +1,27 @@
+/* Test for constant expressions: overflow and constant expressions
+ with -fwrapv: overflows still count as such for the purposes of
+ constant expressions even when they have defined values at
+ runtime. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors -fwrapv" } */
+
+#include <limits.h>
+
+enum e {
+ E0 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 12 } */
+ E1 = 0 * (INT_MIN / -1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 14 } */
+ E2 = 0 * (INT_MAX * INT_MAX), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 16 } */
+ E3 = 0 * (INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 18 } */
+ E4 = 0 * (unsigned)(INT_MIN - 1), /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 20 } */
+ E5 = 0 * -INT_MIN, /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 22 } */
+ E6 = 0 * !-INT_MIN, /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "not an integer constant" "constant" { target *-*-* } 24 } */
+ E7 = INT_MIN % -1 /* Not an overflow. */
+};
diff --git a/gcc/testsuite/gcc.dg/c99-const-expr-9.c b/gcc/testsuite/gcc.dg/c99-const-expr-9.c
new file mode 100644
index 0000000..48f43ed
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/c99-const-expr-9.c
@@ -0,0 +1,26 @@
+/* Test for constant expressions: __builtin_offsetof allowed in
+ integer constant expressions but not traditional offsetof
+ expansion. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
+
+struct s {
+ int a;
+};
+
+struct t {
+ struct s a;
+ int b[2];
+};
+
+#define old_offsetof(TYPE, MEMBER) ((__SIZE_TYPE__) &((TYPE *)0)->MEMBER)
+
+enum e {
+ E1 = old_offsetof (struct s, a), /* { dg-error "constant" } */
+ E2 = old_offsetof (struct t, a.a), /* { dg-error "constant" } */
+ E3 = old_offsetof (struct t, b[1]), /* { dg-error "constant" } */
+ E4 = __builtin_offsetof (struct s, a),
+ E5 = __builtin_offsetof (struct t, a.a),
+ E6 = __builtin_offsetof (struct t, b[1])
+};
diff --git a/gcc/testsuite/gcc.dg/c99-static-1.c b/gcc/testsuite/gcc.dg/c99-static-1.c
index 3c817c6..a138f87 100644
--- a/gcc/testsuite/gcc.dg/c99-static-1.c
+++ b/gcc/testsuite/gcc.dg/c99-static-1.c
@@ -27,7 +27,7 @@ static int f4(void);
void g4(void) { sizeof(int (*)[f4()]); }
/* Constraint violation (VLA). */
-static int f5(void); /* { dg-error "used but never defined" "VLA" { xfail *-*-* } } */
+static int f5(void); /* { dg-error "used but never defined" "VLA" } */
void g5(void) { sizeof(int [0 ? f5() : 1]); }
/* OK (non-constant sizeof inside constant sizeof). */
diff --git a/gcc/testsuite/gcc.dg/compare10.c b/gcc/testsuite/gcc.dg/compare10.c
new file mode 100644
index 0000000..3b8af28
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/compare10.c
@@ -0,0 +1,16 @@
+/* Test for bogus -Wsign-compare warnings that appeared when not
+ folding operands before warning. */
+/* { dg-do compile } */
+/* { dg-options "-Wsign-compare" } */
+
+int
+test_compare (int a, unsigned b)
+{
+ return (b > 8 * (a ? 4 : 8));
+}
+
+unsigned int
+test_conditional (int a, unsigned b, int c)
+{
+ return (c ? b : 8 * (a ? 4 : 8));
+}
diff --git a/gcc/testsuite/gcc.dg/gnu89-const-expr-1.c b/gcc/testsuite/gcc.dg/gnu89-const-expr-1.c
new file mode 100644
index 0000000..ebc6885
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu89-const-expr-1.c
@@ -0,0 +1,47 @@
+/* Test for constant expressions: GNU extensions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89" } */
+
+int n;
+
+void
+f (void)
+{
+ int i = 0;
+ int a[n];
+ enum e1 {
+ /* Integer constant expressions may not contain statement
+ expressions (not a permitted operand). */
+ E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant" } */
+ /* Real and imaginary parts act like other arithmetic
+ operators. */
+ E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E3 = __real__ 0,
+ E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E5 = __imag__ 0,
+ /* __alignof__ always constant. */
+ E6 = __alignof__ (int[n]),
+ E7 = __alignof__ (a),
+ /* __extension__ ignored for constant expression purposes. */
+ E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E9 = __extension__ 0,
+ /* Conditional expressions with omitted arguments act like the
+ standard type. */
+ E10 = (1 ? : i++), /* { dg-error "constant" } */
+ E11 = (1 ? : 0)
+ };
+ enum e2 {
+ /* Complex integer constants may be cast directly to integer
+ types, but not after further arithmetic on them. */
+ F1 = (int) (_Complex int) 2i, /* { dg-error "constant" } */
+ F2 = (int) +2i, /* { dg-error "constant" } */
+ F3 = (int) (1 + 2i), /* { dg-error "constant" } */
+ F4 = (int) 2i
+ };
+ static double dr = __real__ (1.0 + 2.0i);
+ static double di = __imag__ (1.0 + 2.0i);
+ /* Statement expressions allowed in unevaluated subexpressions in
+ initializers in gnu99 but not gnu89. */
+ static int j = (1 ? 0 : ({ 0; })); /* { dg-warning "constant expression" } */
+}
diff --git a/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c b/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c
new file mode 100644
index 0000000..3395b55
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu89-const-expr-2.c
@@ -0,0 +1,23 @@
+/* Test for constant expressions: __builtin_choose_expr. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu89 -pedantic-errors" } */
+
+#include <limits.h>
+
+int a, b, c;
+
+void
+f (void)
+{
+ /* __builtin_choose_expr acts exactly like the chosen argument for
+ all constant expression purposes. */
+ enum e {
+ E1 = __builtin_choose_expr (1, 1, ++b)
+ };
+ /* The first argument to __builtin_choose_expr must be an integer
+ constant expression. */
+ a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */
+ a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
+}
diff --git a/gcc/testsuite/gcc.dg/gnu99-const-expr-1.c b/gcc/testsuite/gcc.dg/gnu99-const-expr-1.c
new file mode 100644
index 0000000..dcc976e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu99-const-expr-1.c
@@ -0,0 +1,47 @@
+/* Test for constant expressions: GNU extensions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99" } */
+
+int n;
+
+void
+f (void)
+{
+ int i = 0;
+ int a[n];
+ enum e1 {
+ /* Integer constant expressions may not contain statement
+ expressions (not a permitted operand). */
+ E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant" } */
+ /* Real and imaginary parts act like other arithmetic
+ operators. */
+ E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E3 = __real__ 0,
+ E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E5 = __imag__ 0,
+ /* __alignof__ always constant. */
+ E6 = __alignof__ (int[n]),
+ E7 = __alignof__ (a),
+ /* __extension__ ignored for constant expression purposes. */
+ E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E9 = __extension__ 0,
+ /* Conditional expressions with omitted arguments act like the
+ standard type. */
+ E10 = (1 ? : i++), /* { dg-error "constant" } */
+ E11 = (1 ? : 0)
+ };
+ enum e2 {
+ /* Complex integer constants may be cast directly to integer
+ types, but not after further arithmetic on them. */
+ F1 = (int) (_Complex int) 2i, /* { dg-error "constant" } */
+ F2 = (int) +2i, /* { dg-error "constant" } */
+ F3 = (int) (1 + 2i), /* { dg-error "constant" } */
+ F4 = (int) 2i
+ };
+ static double dr = __real__ (1.0 + 2.0i);
+ static double di = __imag__ (1.0 + 2.0i);
+ /* Statement expressions allowed in unevaluated subexpressions in
+ initializers in gnu99 but not gnu89. */
+ static int j = (1 ? 0 : ({ 0; }));
+}
diff --git a/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c b/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c
new file mode 100644
index 0000000..f868c53
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu99-const-expr-2.c
@@ -0,0 +1,23 @@
+/* Test for constant expressions: __builtin_choose_expr. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic-errors" } */
+
+#include <limits.h>
+
+int a, b, c;
+
+void
+f (void)
+{
+ /* __builtin_choose_expr acts exactly like the chosen argument for
+ all constant expression purposes. */
+ enum e {
+ E1 = __builtin_choose_expr (1, 1, ++b)
+ };
+ /* The first argument to __builtin_choose_expr must be an integer
+ constant expression. */
+ a = __builtin_choose_expr ((void *)0, b, c); /* { dg-error "constant" } */
+ a = __builtin_choose_expr (0 * (INT_MAX + 1), b, c); /* { dg-warning "integer overflow in expression" } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
+}
diff --git a/gcc/testsuite/gcc.dg/gnu99-const-expr-3.c b/gcc/testsuite/gcc.dg/gnu99-const-expr-3.c
new file mode 100644
index 0000000..aba7da5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu99-const-expr-3.c
@@ -0,0 +1,32 @@
+/* Test for constant expressions: cases involving VLAs and typeof. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu99 -pedantic-errors" } */
+
+/* It appears address constants may contain casts to variably modified
+ types. Whether they should be permitted was discussed in
+ <http://groups.google.com/group/comp.std.c/msg/923eee5ab690fd98>
+ <LV7g2Vy3ARF$Ew9Q@romana.davros.org>; since static pointers to VLAs
+ are definitely permitted within functions and may be initialized
+ and such initialization involves implicit conversion to a variably
+ modified type, allowing explicit casts seems appropriate. Thus,
+ GCC allows them as long as the "evaluated" size expressions do not
+ contain the various operators not permitted to be evaluated in a
+ constant expression, and as long as the result is genuinely
+ constant (meaning that pointer arithmetic using the size of the VLA
+ is generally not permitted). */
+
+static int sa[100];
+
+int
+f (int m, int n)
+{
+ static int (*a1)[n] = &sa;
+ static int (*a2)[n] = (__typeof__(int (*)[n]))sa;
+ static int (*a3)[n] = (__typeof__(int (*)[(int){m++}]))sa; /* { dg-error "constant" } */
+ static int (*a4)[n] = (__typeof__((int (*)[n])sa))sa;
+ static int (*a5)[n] = (__typeof__((int (*)[m++])sa))sa; /* { dg-error "constant" } */
+ static int (*a6)[n] = (__typeof__((int (*)[100])(int (*)[m++])sa))sa;
+ static int (*a7)[n] = (__typeof__((int (*)[n])sa + m++))sa; /* { dg-error "constant" } */
+ return n;
+}
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-1.c b/gcc/testsuite/gcc.dg/overflow-warn-1.c
index 9f76387..633d70b 100644
--- a/gcc/testsuite/gcc.dg/overflow-warn-1.c
+++ b/gcc/testsuite/gcc.dg/overflow-warn-1.c
@@ -17,7 +17,7 @@ enum e {
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */
+ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
/* Again, overflow in evaluated subexpression. */
E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
@@ -28,6 +28,7 @@ enum e {
struct s {
int a;
int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
+ /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 30 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
};
@@ -46,9 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" }
constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 48 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 49 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { xfail *-*-* } 50 } */
+/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 51 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 51 } */
void *r = (1 ? 0 : INT_MAX+1);
void
@@ -57,6 +59,7 @@ g (int i)
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
+ /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } 61 } */
;
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
;
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-2.c b/gcc/testsuite/gcc.dg/overflow-warn-2.c
index 7da8432..e8bbd24 100644
--- a/gcc/testsuite/gcc.dg/overflow-warn-2.c
+++ b/gcc/testsuite/gcc.dg/overflow-warn-2.c
@@ -17,7 +17,7 @@ enum e {
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */
+ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
/* Again, overflow in evaluated subexpression. */
E6 = 0 * (INT_MAX + 1), /* { dg-warning "integer overflow in expression" } */
@@ -28,6 +28,7 @@ enum e {
struct s {
int a;
int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
+ /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 30 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
};
@@ -46,9 +47,10 @@ static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" }
constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 48 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 49 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { xfail *-*-* } 50 } */
+/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 51 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 51 } */
void *r = (1 ? 0 : INT_MAX+1);
void
@@ -57,6 +59,7 @@ g (int i)
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
+ /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } 61 } */
;
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
;
@@ -82,23 +85,23 @@ void
h2 (void)
{
fsc (SCHAR_MAX + 1);
- /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 84 } */
+ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 87 } */
fsc (SCHAR_MIN - 1); /* { dg-warning "overflow in implicit constant conversion" } */
- /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 86 } */
+ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 89 } */
fsc (UCHAR_MAX);
- /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 88 } */
+ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 91 } */
fsc (UCHAR_MAX + 1); /* { dg-warning "overflow in implicit constant conversion" } */
- /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 90 } */
+ /* { dg-warning "passing argument 1 of 'fsc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 93 } */
fuc (-1);
- /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 92 } */
+ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 95 } */
fuc (UCHAR_MAX + 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
- /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 94 } */
+ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 97 } */
fuc (SCHAR_MIN);
- /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 96 } */
+ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 99 } */
fuc (SCHAR_MIN - 1); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
- /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 98 } */
+ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 101 } */
fuc (-UCHAR_MAX); /* { dg-warning "large integer implicitly truncated to unsigned type" } */
- /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 100 } */
+ /* { dg-warning "passing argument 1 of 'fuc' with different width due to prototype" "-Wtraditional-conversion" { target *-*-* } 103 } */
}
void fui (unsigned int);
@@ -122,11 +125,11 @@ h2i (int x)
fsi (UINT_MAX); /* { dg-warning "passing argument 1 of 'fsi' as signed due to prototype" } */
si = UINT_MAX;
fui (-1);
- /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 124 } */
+ /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 127 } */
ui = -1;
ui = x ? -1 : 1U;
fui (INT_MIN);
- /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 128 } */
+ /* { dg-warning "passing argument 1 of 'fui' as unsigned due to prototype" "-Wtraditional-conversion" { target *-*-* } 131 } */
ui = INT_MIN;
ui = x ? INT_MIN : 1U;
}
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-3.c b/gcc/testsuite/gcc.dg/overflow-warn-3.c
index 6b1dc05..d9a3ae4 100644
--- a/gcc/testsuite/gcc.dg/overflow-warn-3.c
+++ b/gcc/testsuite/gcc.dg/overflow-warn-3.c
@@ -17,7 +17,7 @@ enum e {
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */
+ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 21 } */
/* Again, overflow in evaluated subexpression. */
@@ -30,8 +30,9 @@ enum e {
struct s {
int a;
int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
+ /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 32 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
- /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 33 } */
+ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 34 } */
};
void
@@ -45,16 +46,17 @@ f (void)
/* But this expression does need to be constant. */
static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
-/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 47 } */
+/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 48 } */
/* The first two of these involve overflow, so are not null pointer
constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
-/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 53 } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 53 } */
+/* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 54 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 54 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
-/* { dg-warning "initialization makes pointer from integer without a cast" "null" { xfail *-*-* } 56 } */
+/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 57 } */
+/* { dg-warning "initialization makes pointer from integer without a cast" "null" { target *-*-* } 57 } */
void *r = (1 ? 0 : INT_MAX+1);
void
@@ -63,9 +65,10 @@ g (int i)
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
+ /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } 67 } */
;
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
- /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 67 } */
+ /* { dg-warning "overflow in constant expression" "constant" { target *-*-* } 70 } */
;
}
}
diff --git a/gcc/testsuite/gcc.dg/overflow-warn-4.c b/gcc/testsuite/gcc.dg/overflow-warn-4.c
index 1e2518f..7b7e23c 100644
--- a/gcc/testsuite/gcc.dg/overflow-warn-4.c
+++ b/gcc/testsuite/gcc.dg/overflow-warn-4.c
@@ -17,7 +17,7 @@ enum e {
/* But as in DR#031, the 1/0 in an evaluated subexpression means the
whole expression violates the constraints. */
E4 = 0 * (1 / 0), /* { dg-warning "division by zero" } */
- /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { xfail *-*-* } 19 } */
+ /* { dg-error "enumerator value for 'E4' is not an integer constant" "enum error" { target *-*-* } 19 } */
E5 = INT_MAX + 1, /* { dg-warning "integer overflow in expression" } */
/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 21 } */
/* Again, overflow in evaluated subexpression. */
@@ -30,8 +30,9 @@ enum e {
struct s {
int a;
int : 0 * (1 / 0); /* { dg-warning "division by zero" } */
+ /* { dg-error "not an integer constant" "integer constant" { target *-*-* } 32 } */
int : 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 33 } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 34 } */
};
void
@@ -45,16 +46,17 @@ f (void)
/* But this expression does need to be constant. */
static int sc = INT_MAX + 1; /* { dg-warning "integer overflow in expression" } */
-/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 47 } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 48 } */
/* The first two of these involve overflow, so are not null pointer
constants. The third has the overflow in an unevaluated
subexpression, so is a null pointer constant. */
void *p = 0 * (INT_MAX + 1); /* { dg-warning "integer overflow in expression" } */
-/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 53 } */
-/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 53 } */
+/* { dg-error "overflow in constant expression" "constant" { target *-*-* } 54 } */
+/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 54 } */
void *q = 0 * (1 / 0); /* { dg-warning "division by zero" } */
-/* { dg-error "initialization makes pointer from integer without a cast" "null" { xfail *-*-* } 56 } */
+/* { dg-error "initializer element is not constant" "constant" { target *-*-* } 57 } */
+/* { dg-error "initialization makes pointer from integer without a cast" "null" { target *-*-* } 57 } */
void *r = (1 ? 0 : INT_MAX+1);
void
@@ -63,9 +65,10 @@ g (int i)
switch (i)
{
case 0 * (1/0): /* { dg-warning "division by zero" } */
+ /* { dg-error "case label does not reduce to an integer constant" "constant" { target *-*-* } 67 } */
;
case 1 + 0 * (INT_MAX + 1): /* { dg-warning "integer overflow in expression" } */
- /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 67 } */
+ /* { dg-error "overflow in constant expression" "constant" { target *-*-* } 70 } */
;
}
}
diff --git a/gcc/testsuite/gcc.dg/pr14649-1.c b/gcc/testsuite/gcc.dg/pr14649-1.c
index 83a9f57..34f42f0 100644
--- a/gcc/testsuite/gcc.dg/pr14649-1.c
+++ b/gcc/testsuite/gcc.dg/pr14649-1.c
@@ -4,7 +4,7 @@
double atan(double);
-const double pi = 4*atan(1.0); /* { dg-warning "(not constant)|(near initialization)" } */
+const double pi = 4*atan(1.0); /* { dg-warning "not a constant expression" } */
const double ok = 4*__builtin_atan(1.0);
diff --git a/gcc/testsuite/gcc.dg/pr19984.c b/gcc/testsuite/gcc.dg/pr19984.c
index 1b61d7f..5323c46 100644
--- a/gcc/testsuite/gcc.dg/pr19984.c
+++ b/gcc/testsuite/gcc.dg/pr19984.c
@@ -5,7 +5,7 @@
double nan (const char *);
-const double nok = nan (""); /* { dg-warning "(not constant)|(near initialization)" } */
+const double nok = nan (""); /* { dg-warning "(not a constant)|(near initialization)" } */
const double ok = __builtin_nan ("");
diff --git a/gcc/testsuite/gcc.dg/pr25682.c b/gcc/testsuite/gcc.dg/pr25682.c
index 4118862..c99b891 100644
--- a/gcc/testsuite/gcc.dg/pr25682.c
+++ b/gcc/testsuite/gcc.dg/pr25682.c
@@ -10,10 +10,10 @@ struct S
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];
+char c[(char *) &((struct S *) 0)->b - (char *) 0]; /* { dg-error "variable-size" } */
+char d[(__SIZE_TYPE__) &((struct S *) 8)->b]; /* { dg-error "variable-size" } */
+char e[sizeof (c) == __builtin_offsetof (struct S, b) ? 1 : -1]; /* { dg-error "variably modified" } */
+char f[sizeof (d) == __builtin_offsetof (struct S, b) + 8 ? 1 : -1]; /* { dg-error "variably modified" } */
extern void bar (char *, char *);
diff --git a/gcc/testsuite/gcc.dg/real-const-1.c b/gcc/testsuite/gcc.dg/real-const-1.c
index 3e2bbfd..4c7058d 100644
--- a/gcc/testsuite/gcc.dg/real-const-1.c
+++ b/gcc/testsuite/gcc.dg/real-const-1.c
@@ -1,4 +1,5 @@
/* PR middle-end/21781. */
/* { dg-do compile } */
+/* { dg-options "-Wall" } */
-int f[.0e200000000 == 0?1:-1];
+int foo(void) { if (.0e200000000 == 0 ) return 1; }
diff --git a/gcc/testsuite/gcc.dg/vect/pr32230.c b/gcc/testsuite/gcc.dg/vect/pr32230.c
index ed1e7b1..bdb290a 100644
--- a/gcc/testsuite/gcc.dg/vect/pr32230.c
+++ b/gcc/testsuite/gcc.dg/vect/pr32230.c
@@ -16,7 +16,7 @@ const_f (filter_buffer_t *buf)
int i;
for (i = 0; i < 10; i++)
- ((float*) (&((sbuf_header_t *) ((buf) == (filter_buffer_t *)&(buf)->buf[0]))->buf[0]))[i] = val;
+ ((float*) (&((sbuf_header_t *) (__PTRDIFF_TYPE__)((buf) == (filter_buffer_t *)&(buf)->buf[0]))->buf[0]))[i] = val;
}
/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vla-12.c b/gcc/testsuite/gcc.dg/vla-12.c
new file mode 100644
index 0000000..604ea88
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-12.c
@@ -0,0 +1,50 @@
+/* Test for typeof evaluation: should be at the appropriate point in
+ the containing expression rather than just adding a statement. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+extern void exit (int);
+extern void abort (void);
+
+void *p;
+
+void
+f1 (void)
+{
+ int i = 0, j = -1, k = -1;
+ /* typeof applied to expression with cast. */
+ (j = ++i), (void)(typeof ((int (*)[(k = ++i)])p))p;
+ if (j != 1 || k != 2 || i != 2)
+ abort ();
+}
+
+void
+f2 (void)
+{
+ int i = 0, j = -1, k = -1;
+ /* typeof applied to type. */
+ (j = ++i), (void)(typeof (int (*)[(k = ++i)]))p;
+ if (j != 1 || k != 2 || i != 2)
+ abort ();
+}
+
+void
+f3 (void)
+{
+ int i = 0, j = -1, k = -1;
+ void *q;
+ /* typeof applied to expression with cast that is used. */
+ (j = ++i), (void)((typeof (1 + (int (*)[(k = ++i)])p))p);
+ if (j != 1 || k != 2 || i != 2)
+ abort ();
+}
+
+int
+main (void)
+{
+ f1 ();
+ f2 ();
+ f3 ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/vla-13.c b/gcc/testsuite/gcc.dg/vla-13.c
new file mode 100644
index 0000000..70b6305
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-13.c
@@ -0,0 +1,99 @@
+/* Test for VLA size evaluation; see PR 35198. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+
+extern void exit (int);
+extern void abort (void);
+
+int i;
+void *p;
+
+void
+f1 (void *x, int j)
+{
+ p = (int (*)[++i])x;
+ if (i != j)
+ abort ();
+}
+
+void
+f1c (void *x, int j)
+{
+ p = (int (*)[++i]){x};
+ if (i != j)
+ abort ();
+}
+
+void
+f2 (void *x, int j)
+{
+ x = (void *)(int (*)[++i])p;
+ if (i != j)
+ abort ();
+}
+
+void
+f2c (void *x, int j)
+{
+ x = (void *)(int (*)[++i]){p};
+ if (i != j)
+ abort ();
+}
+
+void
+f3 (void *x, int j)
+{
+ (void)(int (*)[++i])p;
+ if (i != j)
+ abort ();
+}
+
+void
+f3c (void *x, int j)
+{
+ (void)(int (*)[++i]){p};
+ if (i != j)
+ abort ();
+}
+
+void
+f4 (void *x, int j)
+{
+ (int (*)[++i])p;
+ (int (*)[++i])p;
+ if (i != j)
+ abort ();
+}
+
+void
+f4c (void *x, int j)
+{
+ (int (*)[++i]){p};
+ (int (*)[++i]){p};
+ if (i != j)
+ abort ();
+}
+
+void
+f5c (void *x, int j, int k)
+{
+ (++i, f3c (x, j), (int (*)[++i]){p});
+ if (i != k)
+ abort ();
+}
+
+int
+main (void)
+{
+ f1 (p, 1);
+ f2 (p, 2);
+ f3 (p, 3);
+ f4 (p, 5);
+ f1c (p, 6);
+ f2c (p, 7);
+ f3c (p, 8);
+ f4c (p, 10);
+ f5c (p, 12, 13);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/vla-14.c b/gcc/testsuite/gcc.dg/vla-14.c
new file mode 100644
index 0000000..3dbb11e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-14.c
@@ -0,0 +1,33 @@
+/* Test for VLA size evaluation in va_arg. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+#include <stdarg.h>
+
+extern void exit (int);
+extern void abort (void);
+
+int a[10];
+int i = 9;
+
+void
+f (int n, ...)
+{
+ va_list ap;
+ void *p;
+ va_start (ap, n);
+ p = va_arg (ap, typeof (int (*)[++i]));
+ if (p != a)
+ abort ();
+ if (i != n)
+ abort ();
+ va_end (ap);
+}
+
+int
+main (void)
+{
+ f (10, &a);
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/vla-15.c b/gcc/testsuite/gcc.dg/vla-15.c
new file mode 100644
index 0000000..800163b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-15.c
@@ -0,0 +1,27 @@
+/* Test for VLA size evaluation in sizeof typeof. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+#include <stdarg.h>
+
+extern void exit (int);
+extern void abort (void);
+
+char a[1];
+
+void
+f1 (void)
+{
+ int i = 0;
+ int j = sizeof (typeof (*(++i, (char (*)[i])a)));
+ if (i != 1 || j != 1)
+ abort ();
+}
+
+int
+main (void)
+{
+ f1 ();
+ exit (0);
+}
diff --git a/gcc/testsuite/gcc.dg/vla-16.c b/gcc/testsuite/gcc.dg/vla-16.c
new file mode 100644
index 0000000..05e751a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vla-16.c
@@ -0,0 +1,70 @@
+/* Test for modifying and taking addresses of compound literals whose
+ variably modified types involve typeof. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do run } */
+/* { dg-options "-std=gnu99" } */
+
+#include <stdarg.h>
+
+extern void exit (int);
+extern void abort (void);
+
+int a[1];
+
+void
+f1 (void)
+{
+ int i = 0;
+ int (**p)[1] = &(typeof (++i, (int (*)[i])a)){&a};
+ if (*p != &a)
+ abort ();
+ if (i != 1)
+ abort ();
+}
+
+void
+f2 (void)
+{
+ int i = 0;
+ (typeof (++i, (int (*)[i])a)){&a} = 0;
+ if (i != 1)
+ abort ();
+}
+
+void
+f3 (void)
+{
+ int i = 0;
+ (typeof (++i, (int (*)[i])a)){&a} += 1;
+ if (i != 1)
+ abort ();
+}
+
+void
+f4 (void)
+{
+ int i = 0;
+ --(typeof (++i, (int (*)[i])a)){&a + 1};
+ if (i != 1)
+ abort ();
+}
+
+void
+f5 (void)
+{
+ int i = 0;
+ (typeof (++i, (int (*)[i])a)){&a}++;
+ if (i != 1)
+ abort ();
+}
+
+int
+main (void)
+{
+ f1 ();
+ f2 ();
+ f3 ();
+ f4 ();
+ f5 ();
+ exit (0);
+}