annotate gcc/testsuite/g++.dg/cpp2a/bitfield3.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 // P0683R1
kono
parents:
diff changeset
2 // { dg-do compile { target c++11 } }
kono
parents:
diff changeset
3 // { dg-options "" }
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 extern "C" void abort ();
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 int
kono
parents:
diff changeset
8 foo ()
kono
parents:
diff changeset
9 {
kono
parents:
diff changeset
10 return 2;
kono
parents:
diff changeset
11 }
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 int a = foo ();
kono
parents:
diff changeset
14 const int b = 0;
kono
parents:
diff changeset
15 struct S {
kono
parents:
diff changeset
16 int c : 5 = 2 * a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
17 int d : 6 { c + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
18 // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
kono
parents:
diff changeset
19 int e : true ? 7 : a = 3;
kono
parents:
diff changeset
20 int f : (true ? 8 : b) = d + a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
21 int g : (true ? 9 : b) { f + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
22 // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
kono
parents:
diff changeset
23 int h : 1 || new int { 0 };
kono
parents:
diff changeset
24 int i = g + a;
kono
parents:
diff changeset
25 };
kono
parents:
diff changeset
26 S c;
kono
parents:
diff changeset
27 template <bool V, int W>
kono
parents:
diff changeset
28 struct U {
kono
parents:
diff changeset
29 int j : W = 3 * a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
30 int k : W { j + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
31 // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
kono
parents:
diff changeset
32 int l : V ? 7 : a = 3;
kono
parents:
diff changeset
33 int m : (V ? W : b) = k + a; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
34 int n : (V ? W : b) { m + a }; // { dg-warning "default member initializers for bit-fields only available with" "" { target c++17_down } }
kono
parents:
diff changeset
35 // { dg-warning "narrowing conversion of" "" { target *-*-* } .-1 }
kono
parents:
diff changeset
36 int o : 1 || new int { 0 };
kono
parents:
diff changeset
37 int p = n + a;
kono
parents:
diff changeset
38 };
kono
parents:
diff changeset
39 U<true, 10> d;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 int
kono
parents:
diff changeset
42 main ()
kono
parents:
diff changeset
43 {
kono
parents:
diff changeset
44 a = 1;
kono
parents:
diff changeset
45 if (c.c != 4 || c.d != 6 || c.e != 0 || c.f != 8 || c.g != 10 || c.h != 0 || c.i != 12)
kono
parents:
diff changeset
46 abort ();
kono
parents:
diff changeset
47 if (d.j != 6 || d.k != 8 || d.l != 0 || d.m != 10 || d.n != 12 || d.o != 0 || d.p != 14)
kono
parents:
diff changeset
48 abort ();
kono
parents:
diff changeset
49 S s;
kono
parents:
diff changeset
50 U<true, 10> u;
kono
parents:
diff changeset
51 if (s.c != 2 || s.d != 3 || s.f != 4 || s.g != 5 || s.i != 6)
kono
parents:
diff changeset
52 abort ();
kono
parents:
diff changeset
53 if (u.j != 3 || u.k != 4 || u.m != 5 || u.n != 6 || u.p != 7)
kono
parents:
diff changeset
54 abort ();
kono
parents:
diff changeset
55 }