1 /* PR c/66066 */ 2 /* { dg-do compile } */ 3 /* { dg-options "-Wno-div-by-zero -Wpedantic" } */ 4 5 /* Accept these unless -pedantic-errors/-Werror. */ 6 int a1 = -1 << 0; /* { dg-warning "initializer element is not a constant expression" } */ 7 int a2 = -1 << 0 | 0; /* { dg-warning "initializer element is not a constant expression" } */ 8 int a3 = -1 << 0 & 1; /* { dg-warning "initializer element is not a constant expression" } */ 9 int a4 = -1 << 2 ^ 1; /* { dg-warning "initializer element is not a constant expression" } */ 10 int a5 = 4 & -1 << 2; /* { dg-warning "initializer element is not a constant expression" } */ 11 int a6 = (-1 << 2) ^ (1 >> 1); /* { dg-warning "initializer element is not a constant expression" } */ 12 int a7 = 0 || (-1 << 1); /* { dg-warning "initializer element is not a constant expression" } */ 13 int a8 = 0 ? 2 : (-1 << 1); /* { dg-warning "initializer element is not a constant expression" } */ 14 int a9 = 1 && -1 << 0; /* { dg-warning "initializer element is not a constant expression" } */ 15 int a10 = !(-1 << 0); /* { dg-warning "initializer element is not a constant expression" } */ 16 17 /* Don't accept these. */ 18 int b1 = 1 / 0; /* { dg-error "initializer element is not constant" } */ 19 int b2 = 1 / (1 / 0); /* { dg-error "initializer element is not constant" } */ 20 int b3 = 0 ? 2 : 1 / 0; /* { dg-error "initializer element is not constant" } */ 21 int b4 = 0 || 1 / 0; /* { dg-error "initializer element is not constant" } */ 22 int b5 = 0 * (1 / 0); /* { dg-error "initializer element is not constant" } */ 23 int b6 = 1 * (1 / 0); /* { dg-error "initializer element is not constant" } */ 24 int b7 = (1 / 0) * 0; /* { dg-error "initializer element is not constant" } */ 25 int b8 = (1 / 0) * 1; /* { dg-error "initializer element is not constant" } */ 26 int b9 = 1 && 1 / 0; /* { dg-error "initializer element is not constant" } */ 27 int b10 = !(1 / 0); /* { dg-error "initializer element is not constant" } */ 28 int c1 = 1 % 0; /* { dg-error "initializer element is not constant" } */ 29 int c2 = 1 / (1 % 0); /* { dg-error "initializer element is not constant" } */ 30 int c3 = 0 ? 2 : 1 % 0; /* { dg-error "initializer element is not constant" } */ 31 int c4 = 0 || 1 % 0; /* { dg-error "initializer element is not constant" } */ 32 int c5 = 0 * (1 % 0); /* { dg-error "initializer element is not constant" } */ 33 int c6 = 1 * (1 % 0); /* { dg-error "initializer element is not constant" } */ 34 int c7 = (1 % 0) * 0; /* { dg-error "initializer element is not constant" } */ 35 int c8 = (1 % 0) * 1; /* { dg-error "initializer element is not constant" } */ 36 int c9 = 1 && 1 % 0; /* { dg-error "initializer element is not constant" } */ 37 int c10 = !(1 % 0); /* { dg-error "initializer element is not constant" } */ 38