2017-07-04 Jakub Jelinek <jakub@redhat.com>
+ * parser.c (cp_parser_decomposition_declaration): Replace
+ decomposition declaration with structured binding in diagnostics.
+ * decl.c (cp_finish_decomp): Likewise.
+ (grokdeclarator): Likewise.
+
PR c++/81258
* parser.c (cp_parser_decomposition_declaration): Diagnose invalid
forms of structured binding initializers.
if (init == error_mark_node || eltype == error_mark_node)
{
- inform (dloc, "in initialization of decomposition variable %qD",
- v[i]);
+ inform (dloc, "in initialization of structured binding "
+ "variable %qD", v[i]);
goto error_out;
}
/* Save the decltype away before reference collapse. */
break;
case cdk_decomp:
- name = "decomposition";
+ name = "structured binding";
break;
case cdk_error:
? declarator->declarator->id_loc : declarator->id_loc);
if (inlinep)
error_at (declspecs->locations[ds_inline],
- "decomposition declaration cannot be declared %<inline%>");
+ "structured binding declaration cannot be %<inline%>");
if (typedef_p)
error_at (declspecs->locations[ds_typedef],
- "decomposition declaration cannot be declared %<typedef%>");
+ "structured binding declaration cannot be %<typedef%>");
if (constexpr_p)
- error_at (declspecs->locations[ds_constexpr], "decomposition "
- "declaration cannot be declared %<constexpr%>");
+ error_at (declspecs->locations[ds_constexpr], "structured "
+ "binding declaration cannot be %<constexpr%>");
if (thread_p)
error_at (declspecs->locations[ds_thread],
- "decomposition declaration cannot be declared %qs",
+ "structured binding declaration cannot be %qs",
declspecs->gnu_thread_keyword_p
? "__thread" : "thread_local");
if (concept_p)
error_at (declspecs->locations[ds_concept],
- "decomposition declaration cannot be declared %<concept%>");
+ "structured binding declaration cannot be %<concept%>");
switch (storage_class)
{
case sc_none:
break;
case sc_register:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding declaration cannot be "
"%<register%>");
break;
case sc_static:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding declaration cannot be "
"%<static%>");
break;
case sc_extern:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding declaration cannot be "
"%<extern%>");
break;
case sc_mutable:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding declaration cannot be "
"%<mutable%>");
break;
case sc_auto:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding declaration cannot be "
"C++98 %<auto%>");
break;
default:
{
if (type != error_mark_node)
{
- error_at (loc, "decomposition declaration cannot be declared "
- "with type %qT", type);
+ error_at (loc, "structured binding declaration cannot have "
+ "type %qT", type);
inform (loc,
"type must be cv-qualified %<auto%> or reference to "
"cv-qualified %<auto%>");
}
if (cxx_dialect < cxx1z)
- pedwarn (loc, 0, "decomposition declaration only available with "
+ pedwarn (loc, 0, "structured bindings only available with "
"-std=c++1z or -std=gnu++1z");
tree pushed_scope;
if (v.is_empty ())
{
- error_at (loc, "empty decomposition declaration");
+ error_at (loc, "empty structured binding declaration");
decl = error_mark_node;
}
2017-07-04 Jakub Jelinek <jakub@redhat.com>
+ * g++.dg/cpp1z/decomp1.C: Expect structured binding instead of
+ decomposition declaration in diagnostics.
+ * g++.dg/cpp1z/decomp2.C: Likewise.
+ * g++.dg/cpp1z/decomp3.C: Likewise.
+ * g++.dg/cpp1z/decomp4.C: Likewise.
+ * g++.dg/cpp1z/decomp5.C: Likewise.
+ * g++.dg/cpp1z/decomp6.C: Likewise.
+ * g++.dg/cpp1z/decomp7.C: Likewise.
+ * g++.dg/cpp1z/decomp8.C: Likewise.
+ * g++.dg/cpp1z/decomp13.C: Likewise.
+ * g++.dg/cpp1z/decomp14.C: Likewise.
+ * g++.dg/cpp1z/decomp18.C: Likewise.
+ * g++.dg/cpp1z/decomp19.C: Likewise.
+ * g++.dg/cpp1z/decomp22.C: Likewise.
+ * g++.dg/cpp1z/decomp23.C: Likewise.
+ * g++.dg/cpp1z/decomp24.C: Likewise.
+ * g++.dg/cpp1z/decomp25.C: Likewise.
+ * g++.dg/cpp1z/decomp26.C: Likewise.
+ * g++.dg/cpp1z/decomp28.C: Likewise.
+
PR c++/81258
* g++.dg/cpp1z/decomp21.C (foo): Adjust expected diagnostics.
* g++.dg/cpp1z/decomp30.C: New test.
int
main ()
{
- auto & [ c, d ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ e, f ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ g, h, i ] = s; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ j, k, l ] = s; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto & [ c, d ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ e, f ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ g, h, i ] = s; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ j, k, l ] = s; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
c++;
d++;
e += 6;
template<> struct std::tuple_size<B> { static constexpr int value = 2; };
template<int I> struct std::tuple_element<I,B> { typedef int type; };
-auto [ aa, bb, cc, dd ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+auto [ aa, bb, cc, dd ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZDC2aa2bb2cc2ddE" } }
-const auto & [ e, f, g, h ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+const auto & [ e, f, g, h ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZDC1e1f1g1hE" } }
-auto [ ee, ff ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+auto [ ee, ff ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZDC2ee2ffE" } }
-auto & [ gg, hh ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+auto & [ gg, hh ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZDC2gg2hhE" } }
namespace N
{
namespace M
{
- auto [ i, j, k, l ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ i, j, k, l ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZN1N1MDC1i1j1k1lEE" } }
- auto & [ m, n, o, ppp ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto & [ m, n, o, ppp ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZN1N1MDC1m1n1o3pppEE" } }
- auto [ ii, jj ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ ii, jj ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZN1N1MDC2ii2jjEE" } }
// { dg-final { scan-assembler "_ZN1N1M2iiE" } }
// { dg-final { scan-assembler "_ZN1N1M2jjE" } }
- auto & [ mm, nn ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto & [ mm, nn ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZN1N1MDC2mm2nnEE" } }
// { dg-final { scan-assembler "_ZN1N1M2mmE" } }
// { dg-final { scan-assembler "_ZN1N1M2nnE" } }
}
namespace std
{
- auto [ i2, j2, k2, l2 ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ i2, j2, k2, l2 ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZStDC2i22j22k22l2E" } }
- auto [ vv, ww ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ vv, ww ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZStDC2vv2wwE" } }
// { dg-final { scan-assembler "_ZSt2vv" } }
// { dg-final { scan-assembler "_ZSt2ww" } }
}
namespace
{
- auto [ v, w, x, y ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ v, w, x, y ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
}
void
foo (C &c, F &f, G &g, H &h, I &i, K &k, M &m)
{
- auto [ ci ] = c; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ 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 "decomposition declaration only available with" "" { target c++14_down } .-1 }
+ // { 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 "decomposition declaration only available with" "" { target c++14_down } .-1 }
- auto [ hi ] = h; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ // { 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 "decomposition declaration only available with" "" { target c++14_down } .-1 }
- auto [ mi ] = m; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ // { 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 } }
}
foo ()
{
int z = 0;
- for (auto & [ b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto & [ b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
z += b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s;
}
int x = 99;
struct S { int &x; };
S s{x};
- auto [p] = s; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [p] = s; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
return p - 99;
}
int
main ()
{
- auto & [ d, e, f, g ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ h, i, j, k ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ l, m ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ n, o ] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ p, q ] = c; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ r, s ] = c; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto & [ d, e, f, g ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ h, i, j, k ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ l, m ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ n, o ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ p, q ] = c; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ r, s ] = c; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
d += 10;
e += 11;
f += 12;
int
foo (C<int> t)
{
- auto[x0] = t; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto[x0] = t; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
return x0;
}
int
foo (std::tuple<int> t)
{
- auto [x0] = t; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [x0] = t; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
return x0;
}
{
int a {10};
auto [b] { [&a](){} }; // { dg-error "cannot decompose lambda closure type" }
- return b - a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+ return b - a; // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
}
{
enum E { A };
void f () { auto [x] = 0; x++; } // { dg-error "cannot decompose non-array non-class type" }
- // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
void g (T t) { auto [y] = t; y++; } // { dg-error "cannot decompose non-array non-class type" }
-}; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .-1 }
+}; // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
int
main ()
// { dg-do compile { target c++11 } }
// { dg-options "" }
-template<typename T> T &make(); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .+1 }
+template<typename T> T &make(); // { dg-warning "structured bindings only available with" "" { target c++14_down } .+1 }
auto [d1, d2] = make<int>(); // { dg-error "cannot decompose non-array non-class type" }
void
foo (std::tuple<int> b)
{
- auto [c] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [c] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
}
template <typename T>
void
bar (std::tuple<T> b)
{
- auto [c] = b; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [c] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
}
void
int
main ()
{
- [](auto) { [](std::tuple<int> b) { auto[c] = b; }; } (0); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ [](auto) { [](std::tuple<int> b) { auto[c] = b; }; } (0); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
}
void
test (A &b, B c)
{
- int && [ d ] = c; // { dg-error "decomposition declaration cannot be declared with type 'int'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- char & [ e, f, ff ] { b }; // { dg-error "decomposition declaration cannot be declared with type 'char'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto&[g,h,i]=b; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
- decltype (auto) [ j ] = c; // { dg-error "decomposition declaration cannot be declared with type 'decltype.auto.'" "" { target c++14 } }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ int && [ d ] = c; // { dg-error "structured binding declaration cannot have type 'int'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ char & [ e, f, ff ] { b }; // { dg-error "structured binding declaration cannot have type 'char'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto&[g,h,i]=b; // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
+ decltype (auto) [ j ] = c; // { dg-error "structured binding declaration cannot have type 'decltype.auto.'" "" { target c++14 } }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
// { dg-error "expected primary-expression before 'decltype'" "" { target c++11_down } .-2 }
auto & & && & [ m, n, o ] = b; // { dg-error "multiple ref-qualifiers" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- constexpr auto [ p ] = c; // { dg-error "decomposition declaration cannot be declared 'constexpr'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ constexpr auto [ p ] = c; // { dg-error "structured binding declaration cannot be 'constexpr'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
friend auto [ q ] = c; // { dg-error "'friend' used outside of class" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- typedef auto [ r ] = c; // { dg-error "decomposition declaration cannot be declared 'typedef'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- inline auto [ s ] = c; // { dg-error "decomposition declaration cannot be declared 'inline'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ typedef auto [ r ] = c; // { dg-error "structured binding declaration cannot be 'typedef'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ inline auto [ s ] = c; // { dg-error "structured binding declaration cannot be 'inline'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
__restrict auto [ t ] = c; // { dg-error "invalid use of 'restrict'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- long long auto [ u ] = c; // { dg-error "'long long' invalid for 'decomposition'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ long long auto [ u ] = c; // { dg-error "'long long' invalid for 'structured binding'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
virtual auto [ v ] = c; // { dg-error "'virtual' outside class declaration" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
explicit auto [ w ] = c; // { dg-error "'explicit' outside class declaration" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- static auto [ x ] = c; // { dg-error "decomposition declaration cannot be declared 'static'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- extern auto [ y ] { c }; // { dg-error "decomposition declaration cannot be declared 'extern'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ static auto [ x ] = c; // { dg-error "structured binding declaration cannot be 'static'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ extern auto [ y ] { c }; // { dg-error "structured binding declaration cannot be 'extern'" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
void
test3 (A &b, B c)
{
auto [ d, e, f ] = arr; // { dg-error "only 3 names provided while 'int .4.' decomposes into 4 elements" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto & [ g, h, i, j, k ] = arr; // { dg-error "5 names provided while 'int .4.' decomposes into 4 elements" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ l, m ] = b; // { dg-error "only 2 names provided while 'A' decomposes into 3 elements" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto & [ n, o, p, q ] = b; // { dg-error "4 names provided while 'A' decomposes into 3 elements" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto [] { c }; // { dg-error "empty decomposition declaration" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [] { c }; // { dg-error "empty structured binding declaration" }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ r, s ] = c; // { dg-error "2 names provided while 'B' decomposes into 1 elements" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i)
{
auto [ j ] = a; // { dg-error "cannot decompose class type 'A' because it has an anonymous struct member" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ k ] { b }; // { dg-error "cannot decompose class type 'B' because it has an anonymous union member" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [ l, l2 ] = c; // { dg-error "cannot decompose non-public member 'C::b' of 'C'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto [ m ] = d; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ m ] = d; // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
auto [ n ] { e }; // { dg-error "cannot decompose non-public member 'E::a' of 'E'" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto [ o ] { f }; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ o ] { f }; // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
auto & [ p ] { g }; // { dg-error "cannot decompose class type 'G': both it and its base class 'F' have non-static data members" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
- auto [ q ] { h }; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ q ] { h }; // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
auto [ r ] { i }; // { dg-error "cannot decompose class type 'I': its base classes 'F' and 'H' have non-static data members" }
- // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
x.i = i;
x.j = 2 * i++;
}
- for (auto & [ x, y ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto & [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x += 2;
y += 3;
}
i = 0;
- for (const auto [ u, v ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (const auto [ u, v ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
if (u != i + 2 || v != 2 * i++ + 3)
__builtin_abort ();
}
i = 0;
- for (auto [ x, y ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x += 4;
y += 5;
if (ccnt != 6 || dcnt || cccnt || tccnt)
__builtin_abort ();
{
- auto [b,c,d,e,f,g] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [b,c,d,e,f,g] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort ();
b.a++;
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort ();
{
- auto&[ h, i, j, k, l, m ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto&[ h, i, j, k, l, m ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort ();
j.a += 4;
if (ccnt != 12 || dcnt != 12 || cccnt || tccnt != 6)
__builtin_abort ();
{
- auto [b,c,d,e,f,g] { a }; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [b,c,d,e,f,g] { a }; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort ();
b.a++;
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort ();
{
- auto&[ h, i, j, k, l, m ] {a}; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto&[ h, i, j, k, l, m ] {a}; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort ();
j.a += 4;
if (ccnt != 18 || dcnt != 24 || cccnt != 6 || tccnt != 6)
__builtin_abort ();
{
- auto [b,c,d,e,f,g] ( a ); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto [b,c,d,e,f,g] ( a ); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort ();
b.a++;
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort ();
{
- auto&[ h, i, j, k, l, m ] (a); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto&[ h, i, j, k, l, m ] (a); // { dg-warning "structured bindings only available with" "" { target c++14_down } }
if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort ();
j.a += 4;
void
foo (T &x, U &y)
{
- auto & [ c, d ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ e, f ] = a; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ g, h, i ] = sa; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ j, k, l ] = sa; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ m, n ] = x; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ o, p ] = x; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto [ q, r, s ] = y; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
- auto & [ t, u, v ] = y; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ auto & [ c, d ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ e, f ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ g, h, i ] = sa; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ j, k, l ] = sa; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ m, n ] = x; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ o, p ] = x; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto [ q, r, s ] = y; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
+ auto & [ t, u, v ] = y; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
c += 1;
e += 2;
g += 3;
x.i = i;
x.j = 2 * i++;
}
- for (auto & [ x, y ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto & [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x += 2;
y += 3;
}
i = 0;
- for (const auto [ u, v ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (const auto [ u, v ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
if (u != i + 2 || v != 2 * i++ + 3)
__builtin_abort ();
}
i = 0;
- for (auto [ x, y ] : a) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x += 4;
y += 5;
x.i = i;
x.j = 2 * i++;
}
- for (auto & [ x, y ] : b) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto & [ x, y ] : b) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x -= 2;
y -= 3;
}
i = 0;
- for (const auto [ u, v ] : b) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (const auto [ u, v ] : b) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
if (u != i - 2 || v != 2 * i++ - 3)
__builtin_abort ();
}
i = 0;
- for (auto [ x, y ] : b) // { dg-warning "decomposition declaration only available with" "" { target c++14_down } }
+ for (auto [ x, y ] : b) // { dg-warning "structured bindings only available with" "" { target c++14_down } }
{
x -= 4;
y -= 5;