aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c')
-rw-r--r--gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c
new file mode 100644
index 000000000..e05211462
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gcc.dg/gnu90-const-expr-1.c
@@ -0,0 +1,56 @@
+/* Test for constant expressions: GNU extensions. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90 -pedantic-errors" } */
+
+int n;
+
+void
+f (void)
+{
+ int i = 0;
+ int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */
+ enum e1 {
+ /* Integer constant expressions may not contain statement
+ expressions (not a permitted operand). */
+ E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */
+ /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } 16 } */
+ /* Real and imaginary parts act like other arithmetic
+ operators. */
+ E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
+ E3 = __real__ 0,
+ E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
+ E5 = __imag__ 0,
+ /* __alignof__ always constant. */
+ E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */
+ E7 = __alignof__ (a), /* { dg-error "__alignof__ \\(expression\\)" } */
+ /* __extension__ ignored for constant expression purposes. */
+ E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
+ E9 = __extension__ 0,
+ /* Conditional expressions with omitted arguments act like the
+ standard type. */
+ E10 = (1 ? : i++), /* { dg-error "constant expression" } */
+ /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } 32 } */
+ E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */
+ };
+ 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 expression" } */
+ /* { dg-error "complex" "complex" { target *-*-* } 39 } */
+ /* { dg-error "imaginary" "imaginary" { target *-*-* } 39 } */
+ F2 = (int) +2i, /* { dg-error "constant expression" } */
+ /* { dg-error "imaginary" "ISO" { target *-*-* } 42 } */
+ F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */
+ /* { dg-error "imaginary" "ISO" { target *-*-* } 44 } */
+ F4 = (int) 2i /* { dg-error "imaginary" } */
+ };
+ static double dr = __real__ (1.0 + 2.0i);
+ /* { dg-error "imaginary" "ISO" { target *-*-* } 48 } */
+ static double di = __imag__ (1.0 + 2.0i);
+ /* { dg-error "imaginary" "ISO" { target *-*-* } 50 } */
+ /* Statement expressions allowed in unevaluated subexpressions in
+ initializers in gnu99 but not gnu89. */
+ static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */
+ /* { dg-error "braced" "ISO" { target *-*-* } 54 } */
+}