aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp1z/decomp14.C
blob: d05a8903232e028a92571968b7aa45cf231c6b82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// { dg-do compile { target c++11 } }
// { dg-options "" }

struct A { int f; };
struct B { int b; };
struct C : virtual A {};
struct D : virtual A {};
struct E { int f; };
struct F : A { int f; };
struct G : A, E {};
struct H : C, D {};
struct I : A, C {};		// { dg-warning "due to ambiguity" }
struct J : B {};
struct K : B, virtual J {};	// { dg-warning "due to ambiguity" }
struct L : virtual J {};
struct M : virtual J, L {};

void
foo (C &c, F &f, G &g, H &h, I &i, K &k, M &m)
{
  auto [ ci ] = c;		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
  auto [ fi ] = f;		// { dg-error "cannot decompose class type 'F': both it and its base class 'A' have non-static data members" }
				// { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
  auto [ gi ] = g;		// { dg-error "cannot decompose class type 'G': its base classes 'A' and 'E' have non-static data members" }
				// { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
  auto [ hi ] = h;		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
  auto [ ki ] = k;		// { dg-error "'B' is an ambiguous base of 'K'" }
				// { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
  auto [ mi ] = m;		// { dg-warning "structured bindings only available with" "" { target c++14_down } }
}