* [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
@ 2017-06-30 17:26 Jakub Jelinek
2017-06-30 17:39 ` Nathan Sidwell
2017-06-30 19:15 ` Jason Merrill
0 siblings, 2 replies; 9+ messages in thread
From: Jakub Jelinek @ 2017-06-30 17:26 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
Hi!
As C++17 decided to rename decompositions to structured bindings, this
patch attempts to adjust the diagnostics by replacing
"decomposition declaration" with "structured binding".
Or shall I use "structured binding declaration" instead (or is that too
longer/verbose), or something different?
Bootstrapped/regtested on x86_64-linux and i686-linux.
2017-06-30 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.
* 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.
--- gcc/cp/parser.c.jj 2017-06-30 11:03:18.000000000 +0200
+++ gcc/cp/parser.c 2017-06-30 11:23:26.430710676 +0200
@@ -13136,7 +13136,7 @@ cp_parser_decomposition_declaration (cp_
}
if (cxx_dialect < cxx1z)
- pedwarn (loc, 0, "decomposition declaration only available with "
+ pedwarn (loc, 0, "structured binding only available with "
"-std=c++1z or -std=gnu++1z");
tree pushed_scope;
@@ -13185,7 +13185,7 @@ cp_parser_decomposition_declaration (cp_
if (v.is_empty ())
{
- error_at (loc, "empty decomposition declaration");
+ error_at (loc, "empty structured binding");
decl = error_mark_node;
}
--- gcc/cp/decl.c.jj 2017-06-30 09:49:24.000000000 +0200
+++ gcc/cp/decl.c 2017-06-30 11:22:59.496040927 +0200
@@ -7486,8 +7486,8 @@ cp_finish_decomp (tree decl, tree first,
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. */
@@ -10137,7 +10137,7 @@ grokdeclarator (const cp_declarator *dec
break;
case cdk_decomp:
- name = "decomposition";
+ name = "structured binding";
break;
case cdk_error:
@@ -10591,43 +10591,43 @@ grokdeclarator (const cp_declarator *dec
? declarator->declarator->id_loc : declarator->id_loc);
if (inlinep)
error_at (declspecs->locations[ds_inline],
- "decomposition declaration cannot be declared %<inline%>");
+ "structured binding cannot be declared %<inline%>");
if (typedef_p)
error_at (declspecs->locations[ds_typedef],
- "decomposition declaration cannot be declared %<typedef%>");
+ "structured binding cannot be declared %<typedef%>");
if (constexpr_p)
- error_at (declspecs->locations[ds_constexpr], "decomposition "
- "declaration cannot be declared %<constexpr%>");
+ error_at (declspecs->locations[ds_constexpr], "structured "
+ "binding cannot be declared %<constexpr%>");
if (thread_p)
error_at (declspecs->locations[ds_thread],
- "decomposition declaration cannot be declared %qs",
+ "structured binding cannot be declared %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 cannot be declared %<concept%>");
switch (storage_class)
{
case sc_none:
break;
case sc_register:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"%<register%>");
break;
case sc_static:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"%<static%>");
break;
case sc_extern:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"%<extern%>");
break;
case sc_mutable:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"%<mutable%>");
break;
case sc_auto:
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"C++98 %<auto%>");
break;
default:
@@ -10638,7 +10638,7 @@ grokdeclarator (const cp_declarator *dec
{
if (type != error_mark_node)
{
- error_at (loc, "decomposition declaration cannot be declared "
+ error_at (loc, "structured binding cannot be declared "
"with type %qT", type);
inform (loc,
"type must be cv-qualified %<auto%> or reference to "
--- gcc/testsuite/g++.dg/cpp1z/decomp1.C.jj 2016-11-14 08:52:18.309721554 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp1.C 2017-06-30 11:38:33.323750539 +0200
@@ -7,10 +7,10 @@ struct S { int a; signed char b; float c
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 binding only available with" "" { target c++14_down } }
+ auto [ e, f ] = a; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ g, h, i ] = s; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ j, k, l ] = s; // { dg-warning "structured binding only available with" "" { target c++14_down } }
c++;
d++;
e += 6;
--- gcc/testsuite/g++.dg/cpp1z/decomp2.C.jj 2016-11-14 08:52:18.309721554 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp2.C 2017-06-30 11:38:33.370749983 +0200
@@ -9,12 +9,12 @@ __complex__ int c = 7 + 8i;
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 binding only available with" "" { target c++14_down } }
+ auto [ h, i, j, k ] = a; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ l, m ] = b; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ n, o ] = b; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ p, q ] = c; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ r, s ] = c; // { dg-warning "structured binding only available with" "" { target c++14_down } }
d += 10;
e += 11;
f += 12;
--- gcc/testsuite/g++.dg/cpp1z/decomp3.C.jj 2016-11-14 08:52:18.309721554 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp3.C 2017-06-30 11:39:08.560333602 +0200
@@ -9,36 +9,36 @@ B baz ();
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 cannot be declared with type 'int'" }
+ // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ char & [ e, f, ff ] { b }; // { dg-error "structured binding cannot be declared with type 'char'" }
+ // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto&[g,h,i]=b; // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } }
+ decltype (auto) [ j ] = c; // { dg-error "structured binding cannot be declared with type 'decltype.auto.'" "" { target c++14 } }
+ // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ constexpr auto [ p ] = c; // { dg-error "structured binding cannot be declared 'constexpr'" }
+ // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ typedef auto [ r ] = c; // { dg-error "structured binding cannot be declared 'typedef'" }
+ // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ inline auto [ s ] = c; // { dg-error "structured binding cannot be declared 'inline'" }
+ // { dg-warning "structured binding 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 binding 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 binding 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 binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ static auto [ x ] = c; // { dg-error "structured binding cannot be declared 'static'" }
+ // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ extern auto [ y ] { c }; // { dg-error "structured binding cannot be declared 'extern'" }
+ // { dg-warning "structured binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
void
@@ -52,15 +52,15 @@ 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 binding 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 binding 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 binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [] { c }; // { dg-error "empty structured binding" }
+ // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp4.C.jj 2017-01-11 12:03:54.244784029 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp4.C 2017-06-30 11:38:33.379749877 +0200
@@ -15,18 +15,18 @@ void
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 binding 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 binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ m ] = d; // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ o ] { f }; // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
+ auto [ q ] { h }; // { dg-warning "structured binding 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 binding only available with -std=c..1z or -std=gnu..1z" "" { target c++14_down } .-1 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp5.C.jj 2016-11-14 08:52:18.310721542 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp5.C 2017-06-30 11:38:33.406749557 +0200
@@ -12,19 +12,19 @@ main ()
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 binding 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 binding 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 binding only available with" "" { target c++14_down } }
{
x += 4;
y += 5;
--- gcc/testsuite/g++.dg/cpp1z/decomp6.C.jj 2017-01-19 16:58:14.869362536 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp6.C 2017-06-30 11:38:33.411749498 +0200
@@ -23,7 +23,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort ();
b.a++;
@@ -34,7 +34,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 6 || dcnt || cccnt || tccnt != 6)
__builtin_abort ();
j.a += 4;
@@ -59,7 +59,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort ();
b.a++;
@@ -70,7 +70,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 12 || dcnt != 12 || cccnt != 6 || tccnt != 6)
__builtin_abort ();
j.a += 4;
@@ -95,7 +95,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort ();
b.a++;
@@ -106,7 +106,7 @@ main ()
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 binding only available with" "" { target c++14_down } }
if (ccnt != 18 || dcnt != 24 || cccnt != 12 || tccnt != 6)
__builtin_abort ();
j.a += 4;
--- gcc/testsuite/g++.dg/cpp1z/decomp7.C.jj 2016-11-14 08:52:18.310721542 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp7.C 2017-06-30 11:38:33.416749439 +0200
@@ -10,14 +10,14 @@ template <typename T, typename U>
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 binding only available with" "" { target c++14_down } }
+ auto [ e, f ] = a; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ g, h, i ] = sa; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ j, k, l ] = sa; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ m, n ] = x; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ o, p ] = x; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto [ q, r, s ] = y; // { dg-warning "structured binding only available with" "" { target c++14_down } }
+ auto & [ t, u, v ] = y; // { dg-warning "structured binding only available with" "" { target c++14_down } }
c += 1;
e += 2;
g += 3;
--- gcc/testsuite/g++.dg/cpp1z/decomp8.C.jj 2016-11-14 08:52:18.311721530 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp8.C 2017-06-30 11:38:33.421749380 +0200
@@ -14,19 +14,19 @@ foo (T &b)
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 binding 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 binding 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 binding only available with" "" { target c++14_down } }
{
x += 4;
y += 5;
@@ -45,19 +45,19 @@ foo (T &b)
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 binding 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 binding 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 binding only available with" "" { target c++14_down } }
{
x -= 4;
y -= 5;
--- gcc/testsuite/g++.dg/cpp1z/decomp13.C.jj 2016-11-15 18:04:19.185977631 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp13.C 2017-06-30 11:38:32.820756491 +0200
@@ -11,27 +11,27 @@ namespace std {
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 binding 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 binding 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 binding 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 binding 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 binding 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 binding 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 binding 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 binding only available with" "" { target c++14_down } }
// { dg-final { scan-assembler "_ZN1N1MDC2mm2nnEE" } }
// { dg-final { scan-assembler "_ZN1N1M2mmE" } }
// { dg-final { scan-assembler "_ZN1N1M2nnE" } }
@@ -39,14 +39,14 @@ namespace N
}
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 binding 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 binding 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 binding only available with" "" { target c++14_down } }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp14.C.jj 2016-11-15 18:06:17.286482555 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp14.C 2017-06-30 11:38:33.241751510 +0200
@@ -18,13 +18,13 @@ 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 "decomposition declaration only available with" "" { target c++14_down } }
+ auto [ ci ] = c; // { dg-warning "structured binding 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 binding 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 binding only available with" "" { target c++14_down } .-1 }
+ auto [ hi ] = h; // { dg-warning "structured binding 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 binding only available with" "" { target c++14_down } .-1 }
+ auto [ mi ] = m; // { dg-warning "structured binding only available with" "" { target c++14_down } }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp18.C.jj 2016-11-25 09:49:43.067449767 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp18.C 2017-06-30 11:38:33.246751450 +0200
@@ -7,6 +7,6 @@ void
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 binding 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;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp19.C.jj 2017-01-05 22:12:37.429122868 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp19.C 2017-06-30 11:38:33.318750598 +0200
@@ -8,6 +8,6 @@ main ()
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 binding only available with" "" { target c++14_down } }
return p - 99;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp22.C.jj 2017-01-24 23:33:03.471455956 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp22.C 2017-06-30 11:38:33.328750480 +0200
@@ -16,6 +16,6 @@ int &&get (C<E...> &&);
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 binding only available with" "" { target c++14_down } }
return x0;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp23.C.jj 2017-01-24 23:33:03.471455956 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp23.C 2017-06-30 11:38:33.332750433 +0200
@@ -7,6 +7,6 @@
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 binding only available with" "" { target c++14_down } }
return x0;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp24.C.jj 2017-01-25 23:35:44.996344375 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp24.C 2017-06-30 11:38:33.337750374 +0200
@@ -7,5 +7,5 @@ foo ()
{
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 binding only available with" "" { target c++14_down } .-1 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp25.C.jj 2017-02-06 21:02:40.511972113 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp25.C 2017-06-30 11:38:33.342750314 +0200
@@ -7,9 +7,9 @@ struct S
{
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 binding 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 binding only available with" "" { target c++14_down } .-1 }
int
main ()
--- gcc/testsuite/g++.dg/cpp1z/decomp26.C.jj 2017-02-21 18:59:36.565649675 +0100
+++ gcc/testsuite/g++.dg/cpp1z/decomp26.C 2017-06-30 11:38:33.360750101 +0200
@@ -2,5 +2,5 @@
// { 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 binding only available with" "" { target c++14_down } .+1 }
auto [d1, d2] = make<int>(); // { dg-error "cannot decompose non-array non-class type" }
--- gcc/testsuite/g++.dg/cpp1z/decomp28.C.jj 2017-04-11 22:50:15.952478269 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp28.C 2017-06-30 11:38:33.365750042 +0200
@@ -15,14 +15,14 @@ template <int N>
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 binding 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 binding only available with" "" { target c++14_down } }
}
void
@@ -35,5 +35,5 @@ baz (std::tuple<int> b)
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 binding only available with" "" { target c++14_down } }
}
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-06-30 17:26 [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics Jakub Jelinek
@ 2017-06-30 17:39 ` Nathan Sidwell
2017-06-30 19:15 ` Jason Merrill
1 sibling, 0 replies; 9+ messages in thread
From: Nathan Sidwell @ 2017-06-30 17:39 UTC (permalink / raw)
To: Jakub Jelinek, Jason Merrill; +Cc: gcc-patches
On 06/30/2017 01:26 PM, Jakub Jelinek wrote:
> Hi!
>
> As C++17 decided to rename decompositions to structured bindings, this
> patch attempts to adjust the diagnostics by replacing
> "decomposition declaration" with "structured binding".
> Or shall I use "structured binding declaration" instead (or is that too
> longer/verbose), or something different?
IMHO 'structured binding' is fine.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-06-30 17:26 [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics Jakub Jelinek
2017-06-30 17:39 ` Nathan Sidwell
@ 2017-06-30 19:15 ` Jason Merrill
2017-06-30 19:35 ` Jakub Jelinek
1 sibling, 1 reply; 9+ messages in thread
From: Jason Merrill @ 2017-06-30 19:15 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
On Fri, Jun 30, 2017 at 1:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> As C++17 decided to rename decompositions to structured bindings, this
> patch attempts to adjust the diagnostics by replacing
> "decomposition declaration" with "structured binding".
> Or shall I use "structured binding declaration" instead (or is that too
> longer/verbose), or something different?
"structured binding declaration" is better when you're talking about
the declaration syntax. When you're talking about the feature in the
first hunk, "structured bindings". "structured binding variable" is
good in the one hunk where you've used that.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-06-30 19:15 ` Jason Merrill
@ 2017-06-30 19:35 ` Jakub Jelinek
2017-06-30 19:45 ` Jason Merrill
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2017-06-30 19:35 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
On Fri, Jun 30, 2017 at 03:15:21PM -0400, Jason Merrill wrote:
> On Fri, Jun 30, 2017 at 1:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > Hi!
> >
> > As C++17 decided to rename decompositions to structured bindings, this
> > patch attempts to adjust the diagnostics by replacing
> > "decomposition declaration" with "structured binding".
> > Or shall I use "structured binding declaration" instead (or is that too
> > longer/verbose), or something different?
>
> "structured binding declaration" is better when you're talking about
> the declaration syntax. When you're talking about the feature in the
> first hunk, "structured bindings". "structured binding variable" is
> good in the one hunk where you've used that.
What about that:
case cdk_decomp:
- name = "decomposition";
+ name = "structured binding";
break;
hunk?
Also, aren't there too many "declar*" roots, both in the previous
"decomposition declaration cannot be declared"
and
"structured binding declaration cannot be declared"
? I mean wouldn't be "structured bindings cannot be declared"
or "structured binding cannot be declared" better in that case?
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-06-30 19:35 ` Jakub Jelinek
@ 2017-06-30 19:45 ` Jason Merrill
2017-07-03 16:02 ` Jakub Jelinek
0 siblings, 1 reply; 9+ messages in thread
From: Jason Merrill @ 2017-06-30 19:45 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
On Fri, Jun 30, 2017 at 3:35 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jun 30, 2017 at 03:15:21PM -0400, Jason Merrill wrote:
>> On Fri, Jun 30, 2017 at 1:26 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > Hi!
>> >
>> > As C++17 decided to rename decompositions to structured bindings, this
>> > patch attempts to adjust the diagnostics by replacing
>> > "decomposition declaration" with "structured binding".
>> > Or shall I use "structured binding declaration" instead (or is that too
>> > longer/verbose), or something different?
>>
>> "structured binding declaration" is better when you're talking about
>> the declaration syntax. When you're talking about the feature in the
>> first hunk, "structured bindings". "structured binding variable" is
>> good in the one hunk where you've used that.
>
> What about that:
> case cdk_decomp:
> - name = "decomposition";
> + name = "structured binding";
> break;
> hunk?
I think that's OK.
> Also, aren't there too many "declar*" roots, both in the previous
> "decomposition declaration cannot be declared"
> and
> "structured binding declaration cannot be declared"
> ? I mean wouldn't be "structured bindings cannot be declared"
> or "structured binding cannot be declared" better in that case?
Well, the term "structured binding" refers to one of the names
declared by the declaration, not the declaration as a whole, and those
errors refer to the latter. We could change "cannot be declared" to
something else, perhaps just drop the "declared", so e.g. "structured
binding declaration cannot be %<constexpr%>"? Or "cannot use X
specifier"?
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-06-30 19:45 ` Jason Merrill
@ 2017-07-03 16:02 ` Jakub Jelinek
2017-07-03 19:50 ` Jason Merrill
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2017-07-03 16:02 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
Hi!
On Fri, Jun 30, 2017 at 03:44:50PM -0400, Jason Merrill wrote:
> Well, the term "structured binding" refers to one of the names
> declared by the declaration, not the declaration as a whole, and those
> errors refer to the latter. We could change "cannot be declared" to
> something else, perhaps just drop the "declared", so e.g. "structured
> binding declaration cannot be %<constexpr%>"? Or "cannot use X
> specifier"?
So like this?
I've used cannot be %<...%>.
For types where it used to be previously
decomposition declaration cannot be declared with type
I'm using
structured binding declaration cannot have type
(not sure if you have other preference in that case).
2017-07-03 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.
* 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.
--- gcc/cp/parser.c.jj 2017-07-03 17:40:13.292479327 +0200
+++ gcc/cp/parser.c 2017-07-03 17:51:20.389823434 +0200
@@ -13150,7 +13150,7 @@ cp_parser_decomposition_declaration (cp_
}
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;
@@ -13199,7 +13199,7 @@ cp_parser_decomposition_declaration (cp_
if (v.is_empty ())
{
- error_at (loc, "empty decomposition declaration");
+ error_at (loc, "empty structured binding declaration");
decl = error_mark_node;
}
--- gcc/cp/decl.c.jj 2017-06-30 16:51:54.054985468 +0200
+++ gcc/cp/decl.c 2017-07-03 17:51:57.013383043 +0200
@@ -7486,8 +7486,8 @@ cp_finish_decomp (tree decl, tree first,
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. */
@@ -10135,7 +10135,7 @@ grokdeclarator (const cp_declarator *dec
break;
case cdk_decomp:
- name = "decomposition";
+ name = "structured binding";
break;
case cdk_error:
@@ -10589,43 +10589,43 @@ grokdeclarator (const cp_declarator *dec
? 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:
@@ -10636,8 +10636,8 @@ grokdeclarator (const cp_declarator *dec
{
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%>");
--- gcc/testsuite/g++.dg/cpp1z/decomp1.C.jj 2017-06-30 16:46:54.492562687 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp1.C 2017-07-03 17:51:20.410823181 +0200
@@ -7,10 +7,10 @@ struct S { int a; signed char b; float c
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp2.C.jj 2017-06-30 16:46:54.594561469 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp2.C 2017-07-03 17:51:20.411823169 +0200
@@ -9,12 +9,12 @@ __complex__ int c = 7 + 8i;
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp3.C.jj 2017-06-30 16:46:54.692560299 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp3.C 2017-07-03 17:51:20.432822917 +0200
@@ -9,36 +9,36 @@ B baz ();
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
@@ -52,15 +52,15 @@ 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 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp4.C.jj 2017-06-30 16:46:54.750559606 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp4.C 2017-07-03 17:51:20.432822917 +0200
@@ -15,18 +15,18 @@ void
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 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp5.C.jj 2017-06-30 16:46:54.513562436 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp5.C 2017-07-03 17:51:20.432822917 +0200
@@ -12,19 +12,19 @@ main ()
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp6.C.jj 2017-06-30 16:46:54.608561302 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp6.C 2017-07-03 17:51:20.453822664 +0200
@@ -23,7 +23,7 @@ main ()
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++;
@@ -34,7 +34,7 @@ main ()
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;
@@ -59,7 +59,7 @@ main ()
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++;
@@ -70,7 +70,7 @@ main ()
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;
@@ -95,7 +95,7 @@ main ()
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++;
@@ -106,7 +106,7 @@ main ()
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp7.C.jj 2017-06-30 16:46:54.714560036 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp7.C 2017-07-03 17:51:20.453822664 +0200
@@ -10,14 +10,14 @@ template <typename T, typename U>
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp8.C.jj 2017-06-30 16:46:54.763559451 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp8.C 2017-07-03 17:51:20.454822652 +0200
@@ -14,19 +14,19 @@ foo (T &b)
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;
@@ -45,19 +45,19 @@ foo (T &b)
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;
--- gcc/testsuite/g++.dg/cpp1z/decomp13.C.jj 2017-06-30 16:46:54.778559272 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp13.C 2017-07-03 17:51:20.461822568 +0200
@@ -11,27 +11,27 @@ namespace std {
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" } }
@@ -39,14 +39,14 @@ namespace N
}
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 } }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp14.C.jj 2017-06-30 16:46:54.554561946 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp14.C 2017-07-03 17:51:20.474822412 +0200
@@ -18,13 +18,13 @@ 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 "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 } }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp18.C.jj 2017-06-30 16:46:54.565561815 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp18.C 2017-07-03 17:51:20.474822412 +0200
@@ -7,6 +7,6 @@ void
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;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp19.C.jj 2017-06-30 16:46:54.632561015 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp19.C 2017-07-03 17:51:20.475822400 +0200
@@ -8,6 +8,6 @@ main ()
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;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp22.C.jj 2017-06-30 16:46:54.448563212 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp22.C 2017-07-03 17:51:20.487822255 +0200
@@ -16,6 +16,6 @@ int &&get (C<E...> &&);
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;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp23.C.jj 2017-06-30 16:46:54.587561552 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp23.C 2017-07-03 17:51:20.487822255 +0200
@@ -7,6 +7,6 @@
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;
}
--- gcc/testsuite/g++.dg/cpp1z/decomp24.C.jj 2017-06-30 16:46:54.643560884 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp24.C 2017-07-03 17:51:20.488822243 +0200
@@ -7,5 +7,5 @@ foo ()
{
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 }
}
--- gcc/testsuite/g++.dg/cpp1z/decomp25.C.jj 2017-06-30 16:46:54.738559749 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp25.C 2017-07-03 17:51:20.488822243 +0200
@@ -7,9 +7,9 @@ struct S
{
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 ()
--- gcc/testsuite/g++.dg/cpp1z/decomp26.C.jj 2017-06-30 16:46:54.468562973 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp26.C 2017-07-03 17:51:20.488822243 +0200
@@ -2,5 +2,5 @@
// { 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" }
--- gcc/testsuite/g++.dg/cpp1z/decomp28.C.jj 2017-06-30 16:46:54.666560609 +0200
+++ gcc/testsuite/g++.dg/cpp1z/decomp28.C 2017-07-03 17:51:20.489822231 +0200
@@ -15,14 +15,14 @@ template <int N>
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
@@ -35,5 +35,5 @@ baz (std::tuple<int> b)
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 } }
}
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-07-03 16:02 ` Jakub Jelinek
@ 2017-07-03 19:50 ` Jason Merrill
2017-07-03 19:59 ` Jakub Jelinek
0 siblings, 1 reply; 9+ messages in thread
From: Jason Merrill @ 2017-07-03 19:50 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
On Mon, Jul 3, 2017 at 12:02 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> So like this?
Looks good, except...
> case sc_auto:
> - error_at (loc, "decomposition declaration cannot be declared "
> + error_at (loc, "structured binding declaration cannot be "
> "C++98 %<auto%>");
> break;
> default:
This case should just fall into the default gcc_unreachable, we aren't
going to get C++98 auto in C++17 mode.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-07-03 19:50 ` Jason Merrill
@ 2017-07-03 19:59 ` Jakub Jelinek
2017-07-03 21:01 ` Jason Merrill
0 siblings, 1 reply; 9+ messages in thread
From: Jakub Jelinek @ 2017-07-03 19:59 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches List
On Mon, Jul 03, 2017 at 03:50:06PM -0400, Jason Merrill wrote:
> On Mon, Jul 3, 2017 at 12:02 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> > So like this?
>
> Looks good, except...
>
> > case sc_auto:
> > - error_at (loc, "decomposition declaration cannot be declared "
> > + error_at (loc, "structured binding declaration cannot be "
> > "C++98 %<auto%>");
> > break;
> > default:
>
> This case should just fall into the default gcc_unreachable, we aren't
> going to get C++98 auto in C++17 mode.
We actually support structured bindings (with a pedwarn that they are only
available in -std=c++1z) in older std modes (of course, it doesn't make
much sense in -std=c++98, because you always get either the above error
or error that the type of the structured binding is not appropriate; but
for -std=gnu++11 and above it works well).
If I remove the above error_at and fall through into gcc_unreachable,
we'll ICE.
Jakub
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics
2017-07-03 19:59 ` Jakub Jelinek
@ 2017-07-03 21:01 ` Jason Merrill
0 siblings, 0 replies; 9+ messages in thread
From: Jason Merrill @ 2017-07-03 21:01 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches List
On Mon, Jul 3, 2017 at 3:59 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Mon, Jul 03, 2017 at 03:50:06PM -0400, Jason Merrill wrote:
>> On Mon, Jul 3, 2017 at 12:02 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > So like this?
>>
>> Looks good, except...
>>
>> > case sc_auto:
>> > - error_at (loc, "decomposition declaration cannot be declared "
>> > + error_at (loc, "structured binding declaration cannot be "
>> > "C++98 %<auto%>");
>> > break;
>> > default:
>>
>> This case should just fall into the default gcc_unreachable, we aren't
>> going to get C++98 auto in C++17 mode.
>
> We actually support structured bindings (with a pedwarn that they are only
> available in -std=c++1z) in older std modes (of course, it doesn't make
> much sense in -std=c++98, because you always get either the above error
> or error that the type of the structured binding is not appropriate; but
> for -std=gnu++11 and above it works well).
> If I remove the above error_at and fall through into gcc_unreachable,
> we'll ICE.
Ah, OK.
Jason
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2017-07-03 21:01 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-30 17:26 [C++ PATCH] "decomposition declaration" -> "structured binding" in C++ diagnostics Jakub Jelinek
2017-06-30 17:39 ` Nathan Sidwell
2017-06-30 19:15 ` Jason Merrill
2017-06-30 19:35 ` Jakub Jelinek
2017-06-30 19:45 ` Jason Merrill
2017-07-03 16:02 ` Jakub Jelinek
2017-07-03 19:50 ` Jason Merrill
2017-07-03 19:59 ` Jakub Jelinek
2017-07-03 21:01 ` Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).