Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/decomp-bitfield1.C

raw
1 // Test of bit-fields.
2 // { dg-do compile { target c++17 } }
3
4 struct A { long i: 2; } a;
5
6 template <class,class> struct same_type;
7 template <class T> struct same_type<T,T> {};
8
9 void f()
10 {
11 auto [ x ] = a;
12
13 same_type<decltype(x),long>{};
14 same_type<decltype(x+x),int>{};
15
16 long &r = x; // { dg-error "bit" }
17 &x; // { dg-error "bit" }
18 sizeof(x); // { dg-error "10:invalid application of .sizeof. to a bit-field" }
19 }