Commit 8e3b9bbf by Jakub Jelinek Committed by Jakub Jelinek

parser.c (cp_parser_decomposition_declaration): Replace decomposition…

parser.c (cp_parser_decomposition_declaration): Replace decomposition declaration with structured binding in diagnostics.

	* parser.c (cp_parser_decomposition_declaration): Replace
	decomposition declaration with structured binding in diagnostics.
	* decl.c (cp_finish_decomp): Likewise.
	(grokdeclarator): Likewise.

	* 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.

From-SVN: r249948
parent 9fc1fed4
2017-07-04 Jakub Jelinek <jakub@redhat.com> 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 PR c++/81258
* parser.c (cp_parser_decomposition_declaration): Diagnose invalid * parser.c (cp_parser_decomposition_declaration): Diagnose invalid
forms of structured binding initializers. forms of structured binding initializers.
......
...@@ -7486,8 +7486,8 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) ...@@ -7486,8 +7486,8 @@ cp_finish_decomp (tree decl, tree first, unsigned int count)
if (init == error_mark_node || eltype == error_mark_node) if (init == error_mark_node || eltype == error_mark_node)
{ {
inform (dloc, "in initialization of decomposition variable %qD", inform (dloc, "in initialization of structured binding "
v[i]); "variable %qD", v[i]);
goto error_out; goto error_out;
} }
/* Save the decltype away before reference collapse. */ /* Save the decltype away before reference collapse. */
...@@ -10137,7 +10137,7 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10137,7 +10137,7 @@ grokdeclarator (const cp_declarator *declarator,
break; break;
case cdk_decomp: case cdk_decomp:
name = "decomposition"; name = "structured binding";
break; break;
case cdk_error: case cdk_error:
...@@ -10591,43 +10591,43 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10591,43 +10591,43 @@ grokdeclarator (const cp_declarator *declarator,
? declarator->declarator->id_loc : declarator->id_loc); ? declarator->declarator->id_loc : declarator->id_loc);
if (inlinep) if (inlinep)
error_at (declspecs->locations[ds_inline], error_at (declspecs->locations[ds_inline],
"decomposition declaration cannot be declared %<inline%>"); "structured binding declaration cannot be %<inline%>");
if (typedef_p) if (typedef_p)
error_at (declspecs->locations[ds_typedef], error_at (declspecs->locations[ds_typedef],
"decomposition declaration cannot be declared %<typedef%>"); "structured binding declaration cannot be %<typedef%>");
if (constexpr_p) if (constexpr_p)
error_at (declspecs->locations[ds_constexpr], "decomposition " error_at (declspecs->locations[ds_constexpr], "structured "
"declaration cannot be declared %<constexpr%>"); "binding declaration cannot be %<constexpr%>");
if (thread_p) if (thread_p)
error_at (declspecs->locations[ds_thread], error_at (declspecs->locations[ds_thread],
"decomposition declaration cannot be declared %qs", "structured binding declaration cannot be %qs",
declspecs->gnu_thread_keyword_p declspecs->gnu_thread_keyword_p
? "__thread" : "thread_local"); ? "__thread" : "thread_local");
if (concept_p) if (concept_p)
error_at (declspecs->locations[ds_concept], error_at (declspecs->locations[ds_concept],
"decomposition declaration cannot be declared %<concept%>"); "structured binding declaration cannot be %<concept%>");
switch (storage_class) switch (storage_class)
{ {
case sc_none: case sc_none:
break; break;
case sc_register: case sc_register:
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot be "
"%<register%>"); "%<register%>");
break; break;
case sc_static: case sc_static:
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot be "
"%<static%>"); "%<static%>");
break; break;
case sc_extern: case sc_extern:
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot be "
"%<extern%>"); "%<extern%>");
break; break;
case sc_mutable: case sc_mutable:
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot be "
"%<mutable%>"); "%<mutable%>");
break; break;
case sc_auto: case sc_auto:
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot be "
"C++98 %<auto%>"); "C++98 %<auto%>");
break; break;
default: default:
...@@ -10638,8 +10638,8 @@ grokdeclarator (const cp_declarator *declarator, ...@@ -10638,8 +10638,8 @@ grokdeclarator (const cp_declarator *declarator,
{ {
if (type != error_mark_node) if (type != error_mark_node)
{ {
error_at (loc, "decomposition declaration cannot be declared " error_at (loc, "structured binding declaration cannot have "
"with type %qT", type); "type %qT", type);
inform (loc, inform (loc,
"type must be cv-qualified %<auto%> or reference to " "type must be cv-qualified %<auto%> or reference to "
"cv-qualified %<auto%>"); "cv-qualified %<auto%>");
......
...@@ -13150,7 +13150,7 @@ cp_parser_decomposition_declaration (cp_parser *parser, ...@@ -13150,7 +13150,7 @@ cp_parser_decomposition_declaration (cp_parser *parser,
} }
if (cxx_dialect < cxx1z) 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"); "-std=c++1z or -std=gnu++1z");
tree pushed_scope; tree pushed_scope;
...@@ -13199,7 +13199,7 @@ cp_parser_decomposition_declaration (cp_parser *parser, ...@@ -13199,7 +13199,7 @@ cp_parser_decomposition_declaration (cp_parser *parser,
if (v.is_empty ()) if (v.is_empty ())
{ {
error_at (loc, "empty decomposition declaration"); error_at (loc, "empty structured binding declaration");
decl = error_mark_node; decl = error_mark_node;
} }
2017-07-04 Jakub Jelinek <jakub@redhat.com> 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 PR c++/81258
* g++.dg/cpp1z/decomp21.C (foo): Adjust expected diagnostics. * g++.dg/cpp1z/decomp21.C (foo): Adjust expected diagnostics.
* g++.dg/cpp1z/decomp30.C: New test. * g++.dg/cpp1z/decomp30.C: New test.
......
...@@ -7,10 +7,10 @@ struct S { int a; signed char b; float c; } s = { 6, 7, 8.0f }; ...@@ -7,10 +7,10 @@ struct S { int a; signed char b; float c; } s = { 6, 7, 8.0f };
int int
main () main ()
{ {
auto & [ c, d ] = a; // { 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration only available with" "" { target c++14_down } } auto & [ j, k, l ] = s; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
c++; c++;
d++; d++;
e += 6; e += 6;
......
...@@ -11,27 +11,27 @@ namespace std { ...@@ -11,27 +11,27 @@ namespace std {
template<> struct std::tuple_size<B> { static constexpr int value = 2; }; template<> struct std::tuple_size<B> { static constexpr int value = 2; };
template<int I> struct std::tuple_element<I,B> { typedef int type; }; 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" } } // { 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" } } // { 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" } } // { 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" } } // { dg-final { scan-assembler "_ZDC2gg2hhE" } }
namespace N namespace N
{ {
namespace M 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" } } // { 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" } } // { 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 "_ZN1N1MDC2ii2jjEE" } }
// { dg-final { scan-assembler "_ZN1N1M2iiE" } } // { dg-final { scan-assembler "_ZN1N1M2iiE" } }
// { dg-final { scan-assembler "_ZN1N1M2jjE" } } // { 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 "_ZN1N1MDC2mm2nnEE" } }
// { dg-final { scan-assembler "_ZN1N1M2mmE" } } // { dg-final { scan-assembler "_ZN1N1M2mmE" } }
// { dg-final { scan-assembler "_ZN1N1M2nnE" } } // { dg-final { scan-assembler "_ZN1N1M2nnE" } }
...@@ -39,14 +39,14 @@ namespace N ...@@ -39,14 +39,14 @@ namespace N
} }
namespace std 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" } } // { 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 "_ZStDC2vv2wwE" } }
// { dg-final { scan-assembler "_ZSt2vv" } } // { dg-final { scan-assembler "_ZSt2vv" } }
// { dg-final { scan-assembler "_ZSt2ww" } } // { dg-final { scan-assembler "_ZSt2ww" } }
} }
namespace 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 } }
} }
...@@ -18,13 +18,13 @@ struct M : virtual J, L {}; ...@@ -18,13 +18,13 @@ struct M : virtual J, L {};
void void
foo (C &c, F &f, G &g, H &h, I &i, K &k, M &m) 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" } 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" } 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 } // { dg-warning "structured bindings only available with" "" { target c++14_down } .-1 }
auto [ hi ] = h; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } 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'" } auto [ ki ] = k; // { dg-error "'B' is an ambiguous base of 'K'" }
// { 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 [ mi ] = m; // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } auto [ mi ] = m; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
} }
...@@ -7,6 +7,6 @@ void ...@@ -7,6 +7,6 @@ void
foo () foo ()
{ {
int z = 0; 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; z += b + c + d + e + f + g + h + i + j + k + l + m + n + o + p + q + r + s;
} }
...@@ -8,6 +8,6 @@ main () ...@@ -8,6 +8,6 @@ main ()
int x = 99; int x = 99;
struct S { int &x; }; struct S { int &x; };
S s{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; return p - 99;
} }
...@@ -9,12 +9,12 @@ __complex__ int c = 7 + 8i; ...@@ -9,12 +9,12 @@ __complex__ int c = 7 + 8i;
int int
main () main ()
{ {
auto & [ d, e, f, g ] = a; // { 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration only available with" "" { target c++14_down } } auto [ r, s ] = c; // { dg-warning "structured bindings only available with" "" { target c++14_down } }
d += 10; d += 10;
e += 11; e += 11;
f += 12; f += 12;
......
...@@ -16,6 +16,6 @@ int &&get (C<E...> &&); ...@@ -16,6 +16,6 @@ int &&get (C<E...> &&);
int int
foo (C<int> t) 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; return x0;
} }
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
int int
foo (std::tuple<int> t) 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; return x0;
} }
...@@ -7,5 +7,5 @@ foo () ...@@ -7,5 +7,5 @@ foo ()
{ {
int a {10}; int a {10};
auto [b] { [&a](){} }; // { dg-error "cannot decompose lambda closure type" } 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 }
} }
...@@ -7,9 +7,9 @@ struct S ...@@ -7,9 +7,9 @@ struct S
{ {
enum E { A }; enum E { A };
void f () { auto [x] = 0; x++; } // { dg-error "cannot decompose non-array non-class type" } 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" } 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 int
main () main ()
......
...@@ -2,5 +2,5 @@ ...@@ -2,5 +2,5 @@
// { dg-do compile { target c++11 } } // { dg-do compile { target c++11 } }
// { dg-options "" } // { 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" } auto [d1, d2] = make<int>(); // { dg-error "cannot decompose non-array non-class type" }
...@@ -15,14 +15,14 @@ template <int N> ...@@ -15,14 +15,14 @@ template <int N>
void void
foo (std::tuple<int> b) 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> template <typename T>
void void
bar (std::tuple<T> b) 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 void
...@@ -35,5 +35,5 @@ baz (std::tuple<int> b) ...@@ -35,5 +35,5 @@ baz (std::tuple<int> b)
int int
main () 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 } }
} }
...@@ -9,36 +9,36 @@ B baz (); ...@@ -9,36 +9,36 @@ B baz ();
void void
test (A &b, B c) test (A &b, B c)
{ {
int && [ d ] = c; // { dg-error "decomposition declaration cannot be declared with type 'int'" } int && [ d ] = c; // { dg-error "structured binding declaration cannot have type 'int'" }
// { 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 }
char & [ e, f, ff ] { b }; // { dg-error "decomposition declaration cannot be declared with type 'char'" } char & [ e, f, ff ] { b }; // { dg-error "structured binding declaration cannot have type 'char'" }
// { 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]=b; // { dg-warning "decomposition declaration only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } } 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 "decomposition declaration cannot be declared with type 'decltype.auto.'" "" { target c++14 } } decltype (auto) [ j ] = c; // { dg-error "structured binding declaration cannot have 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 } // { 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 } // { dg-error "expected primary-expression before 'decltype'" "" { target c++11_down } .-2 }
auto & & && & [ m, n, o ] = b; // { dg-error "multiple ref-qualifiers" } 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 } // { 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 "decomposition declaration cannot be declared 'constexpr'" } constexpr auto [ p ] = c; // { dg-error "structured binding declaration cannot be '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 }
friend auto [ q ] = c; // { dg-error "'friend' used outside of class" } 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 } // { 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 "decomposition declaration cannot be declared 'typedef'" } typedef auto [ r ] = c; // { dg-error "structured binding declaration cannot be 'typedef'" }
// { 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 }
inline auto [ s ] = c; // { dg-error "decomposition declaration cannot be declared 'inline'" } inline auto [ s ] = c; // { dg-error "structured binding declaration cannot be '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 }
__restrict auto [ t ] = c; // { dg-error "invalid use of 'restrict'" } __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 } // { 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 'decomposition'" } long long auto [ u ] = c; // { dg-error "'long long' invalid for 'structured binding'" }
// { 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 }
virtual auto [ v ] = c; // { dg-error "'virtual' outside class declaration" } 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" } 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 } // { 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 "decomposition declaration cannot be declared 'static'" } static auto [ x ] = c; // { dg-error "structured binding declaration cannot be 'static'" }
// { 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 }
extern auto [ y ] { c }; // { dg-error "decomposition declaration cannot be declared 'extern'" } extern auto [ y ] { c }; // { dg-error "structured binding declaration cannot be '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 }
} }
void void
...@@ -52,15 +52,15 @@ void ...@@ -52,15 +52,15 @@ void
test3 (A &b, B c) test3 (A &b, B c)
{ {
auto [ d, e, f ] = arr; // { dg-error "only 3 names provided while 'int .4.' decomposes into 4 elements" } 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" } 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" } 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" } 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 } // { dg-warning "structured bindings only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
auto [] { c }; // { dg-error "empty decomposition declaration" } auto [] { c }; // { dg-error "empty structured binding 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 [ r, s ] = c; // { dg-error "2 names provided while 'B' decomposes into 1 elements" } 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 }
} }
...@@ -15,18 +15,18 @@ void ...@@ -15,18 +15,18 @@ void
test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i) 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" } 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" } 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'" } 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 } // { dg-warning "structured bindings 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 } } 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'" } 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 } // { dg-warning "structured bindings 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 } } 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" } 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 } // { dg-warning "structured bindings 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 } } 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" } 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 }
} }
...@@ -12,19 +12,19 @@ main () ...@@ -12,19 +12,19 @@ main ()
x.i = i; x.i = i;
x.j = 2 * 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; x += 2;
y += 3; y += 3;
} }
i = 0; 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) if (u != i + 2 || v != 2 * i++ + 3)
__builtin_abort (); __builtin_abort ();
} }
i = 0; 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; x += 4;
y += 5; y += 5;
......
...@@ -23,7 +23,7 @@ main () ...@@ -23,7 +23,7 @@ main ()
if (ccnt != 6 || dcnt || cccnt || tccnt) if (ccnt != 6 || dcnt || cccnt || tccnt)
__builtin_abort (); __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) if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort (); __builtin_abort ();
b.a++; b.a++;
...@@ -34,7 +34,7 @@ main () ...@@ -34,7 +34,7 @@ main ()
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5]) if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort (); __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) if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort (); __builtin_abort ();
j.a += 4; j.a += 4;
...@@ -59,7 +59,7 @@ main () ...@@ -59,7 +59,7 @@ main ()
if (ccnt != 12 || dcnt != 12 || cccnt || tccnt != 6) if (ccnt != 12 || dcnt != 12 || cccnt || tccnt != 6)
__builtin_abort (); __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) if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort (); __builtin_abort ();
b.a++; b.a++;
...@@ -70,7 +70,7 @@ main () ...@@ -70,7 +70,7 @@ main ()
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5]) if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort (); __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) if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort (); __builtin_abort ();
j.a += 4; j.a += 4;
...@@ -95,7 +95,7 @@ main () ...@@ -95,7 +95,7 @@ main ()
if (ccnt != 18 || dcnt != 24 || cccnt != 6 || tccnt != 6) if (ccnt != 18 || dcnt != 24 || cccnt != 6 || tccnt != 6)
__builtin_abort (); __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) if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort (); __builtin_abort ();
b.a++; b.a++;
...@@ -106,7 +106,7 @@ main () ...@@ -106,7 +106,7 @@ main ()
if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5]) if (&b == &a[0] || &c == &a[1] || &d == &a[2] || &e == &a[3] || &f == &a[4] || &g == &a[5])
__builtin_abort (); __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) if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort (); __builtin_abort ();
j.a += 4; j.a += 4;
......
...@@ -10,14 +10,14 @@ template <typename T, typename U> ...@@ -10,14 +10,14 @@ template <typename T, typename U>
void void
foo (T &x, U &y) foo (T &x, U &y)
{ {
auto & [ c, d ] = a; // { 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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 "decomposition declaration 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; c += 1;
e += 2; e += 2;
g += 3; g += 3;
......
...@@ -14,19 +14,19 @@ foo (T &b) ...@@ -14,19 +14,19 @@ foo (T &b)
x.i = i; x.i = i;
x.j = 2 * 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; x += 2;
y += 3; y += 3;
} }
i = 0; 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) if (u != i + 2 || v != 2 * i++ + 3)
__builtin_abort (); __builtin_abort ();
} }
i = 0; 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; x += 4;
y += 5; y += 5;
...@@ -45,19 +45,19 @@ foo (T &b) ...@@ -45,19 +45,19 @@ foo (T &b)
x.i = i; x.i = i;
x.j = 2 * 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; x -= 2;
y -= 3; y -= 3;
} }
i = 0; 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) if (u != i - 2 || v != 2 * i++ - 3)
__builtin_abort (); __builtin_abort ();
} }
i = 0; 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; x -= 4;
y -= 5; y -= 5;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment