From: Jakub Jelinek Date: Tue, 4 Jul 2017 07:40:00 +0000 (+0200) Subject: parser.c (cp_parser_decomposition_declaration): Replace decomposition declaration... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e3b9bbfc850c53fe92b6015005b20b159adfa60;p=gcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 59a71da0546..4dffee44f17 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2017-07-04 Jakub Jelinek + * parser.c (cp_parser_decomposition_declaration): Replace + decomposition declaration with structured binding in diagnostics. + * decl.c (cp_finish_decomp): Likewise. + (grokdeclarator): Likewise. + PR c++/81258 * parser.c (cp_parser_decomposition_declaration): Diagnose invalid forms of structured binding initializers. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d5b758a89ee..43a94d9f6eb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -7486,8 +7486,8 @@ cp_finish_decomp (tree decl, tree first, unsigned int count) 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 *declarator, break; case cdk_decomp: - name = "decomposition"; + name = "structured binding"; break; case cdk_error: @@ -10591,43 +10591,43 @@ grokdeclarator (const cp_declarator *declarator, ? declarator->declarator->id_loc : declarator->id_loc); if (inlinep) error_at (declspecs->locations[ds_inline], - "decomposition declaration cannot be declared %"); + "structured binding declaration cannot be %"); if (typedef_p) error_at (declspecs->locations[ds_typedef], - "decomposition declaration cannot be declared %"); + "structured binding declaration cannot be %"); if (constexpr_p) - error_at (declspecs->locations[ds_constexpr], "decomposition " - "declaration cannot be declared %"); + error_at (declspecs->locations[ds_constexpr], "structured " + "binding declaration cannot be %"); 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 %"); + "structured binding declaration cannot be %"); 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 " "%"); break; case sc_static: - error_at (loc, "decomposition declaration cannot be declared " + error_at (loc, "structured binding declaration cannot be " "%"); break; case sc_extern: - error_at (loc, "decomposition declaration cannot be declared " + error_at (loc, "structured binding declaration cannot be " "%"); break; case sc_mutable: - error_at (loc, "decomposition declaration cannot be declared " + error_at (loc, "structured binding declaration cannot be " "%"); break; case sc_auto: - error_at (loc, "decomposition declaration cannot be declared " + error_at (loc, "structured binding declaration cannot be " "C++98 %"); break; default: @@ -10638,8 +10638,8 @@ grokdeclarator (const cp_declarator *declarator, { 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 % or reference to " "cv-qualified %"); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index de87449283c..dbe00527924 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -13150,7 +13150,7 @@ cp_parser_decomposition_declaration (cp_parser *parser, } 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_parser *parser, if (v.is_empty ()) { - error_at (loc, "empty decomposition declaration"); + error_at (loc, "empty structured binding declaration"); decl = error_mark_node; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7a2e1f0982d..1293cb0ea68 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,25 @@ 2017-07-04 Jakub Jelinek + * g++.dg/cpp1z/decomp1.C: Expect structured binding instead of + decomposition declaration in diagnostics. + * g++.dg/cpp1z/decomp2.C: Likewise. + * g++.dg/cpp1z/decomp3.C: Likewise. + * g++.dg/cpp1z/decomp4.C: Likewise. + * g++.dg/cpp1z/decomp5.C: Likewise. + * g++.dg/cpp1z/decomp6.C: Likewise. + * g++.dg/cpp1z/decomp7.C: Likewise. + * g++.dg/cpp1z/decomp8.C: Likewise. + * g++.dg/cpp1z/decomp13.C: Likewise. + * g++.dg/cpp1z/decomp14.C: Likewise. + * g++.dg/cpp1z/decomp18.C: Likewise. + * g++.dg/cpp1z/decomp19.C: Likewise. + * g++.dg/cpp1z/decomp22.C: Likewise. + * g++.dg/cpp1z/decomp23.C: Likewise. + * g++.dg/cpp1z/decomp24.C: Likewise. + * g++.dg/cpp1z/decomp25.C: Likewise. + * g++.dg/cpp1z/decomp26.C: Likewise. + * g++.dg/cpp1z/decomp28.C: Likewise. + PR c++/81258 * g++.dg/cpp1z/decomp21.C (foo): Adjust expected diagnostics. * g++.dg/cpp1z/decomp30.C: New test. diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp1.C b/gcc/testsuite/g++.dg/cpp1z/decomp1.C index 98f60905e1a..33068917863 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp1.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp1.C @@ -7,10 +7,10 @@ struct S { int a; signed char b; float c; } s = { 6, 7, 8.0f }; 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; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp13.C b/gcc/testsuite/g++.dg/cpp1z/decomp13.C index 9ebddc6e608..a9bf264a2ca 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp13.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp13.C @@ -11,27 +11,27 @@ namespace std { template<> struct std::tuple_size { static constexpr int value = 2; }; template struct std::tuple_element { 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 } } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp14.C b/gcc/testsuite/g++.dg/cpp1z/decomp14.C index 5d6d05fb8a4..d05a8903232 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp14.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp14.C @@ -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 } } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp18.C b/gcc/testsuite/g++.dg/cpp1z/decomp18.C index d5c68a26891..7799e462cdd 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp18.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp18.C @@ -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; } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp19.C b/gcc/testsuite/g++.dg/cpp1z/decomp19.C index e392e658e27..e7d7abfce7c 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp19.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp19.C @@ -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; } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp2.C b/gcc/testsuite/g++.dg/cpp1z/decomp2.C index 5831fc74940..6574028217f 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp2.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp2.C @@ -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; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp22.C b/gcc/testsuite/g++.dg/cpp1z/decomp22.C index 81d40c56931..9e6b8df486a 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp22.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp22.C @@ -16,6 +16,6 @@ int &&get (C &&); int foo (C 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; } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp23.C b/gcc/testsuite/g++.dg/cpp1z/decomp23.C index c682fa00264..9e9278050c9 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp23.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp23.C @@ -7,6 +7,6 @@ int foo (std::tuple 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; } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp24.C b/gcc/testsuite/g++.dg/cpp1z/decomp24.C index 0e874fa6055..4bd519791ff 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp24.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp24.C @@ -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 } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp25.C b/gcc/testsuite/g++.dg/cpp1z/decomp25.C index c99273613bc..d90e665add0 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp25.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp25.C @@ -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 () diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp26.C b/gcc/testsuite/g++.dg/cpp1z/decomp26.C index f413920f545..035433385d7 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp26.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp26.C @@ -2,5 +2,5 @@ // { dg-do compile { target c++11 } } // { dg-options "" } -template T &make(); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } .+1 } +template T &make(); // { dg-warning "structured bindings only available with" "" { target c++14_down } .+1 } auto [d1, d2] = make(); // { dg-error "cannot decompose non-array non-class type" } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp28.C b/gcc/testsuite/g++.dg/cpp1z/decomp28.C index 7561d9dfc02..8b0b5a54999 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp28.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp28.C @@ -15,14 +15,14 @@ template void foo (std::tuple 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 void bar (std::tuple 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 b) int main () { - [](auto) { [](std::tuple b) { auto[c] = b; }; } (0); // { dg-warning "decomposition declaration only available with" "" { target c++14_down } } + [](auto) { [](std::tuple b) { auto[c] = b; }; } (0); // { dg-warning "structured bindings only available with" "" { target c++14_down } } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp3.C b/gcc/testsuite/g++.dg/cpp1z/decomp3.C index a739d3ace37..58ce71bf6ac 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp3.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp3.C @@ -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 } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp4.C b/gcc/testsuite/g++.dg/cpp1z/decomp4.C index bc85263e986..55460833bd9 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp4.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp4.C @@ -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 } } diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp5.C b/gcc/testsuite/g++.dg/cpp1z/decomp5.C index 86b2c22f37a..99610d76832 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp5.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp5.C @@ -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; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp6.C b/gcc/testsuite/g++.dg/cpp1z/decomp6.C index 7a8a239d9e1..378a25141f4 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp6.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp6.C @@ -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; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp7.C b/gcc/testsuite/g++.dg/cpp1z/decomp7.C index d366adecc4c..545c5cf1060 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp7.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp7.C @@ -10,14 +10,14 @@ template 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; diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp8.C b/gcc/testsuite/g++.dg/cpp1z/decomp8.C index 9e1ea5d5da1..af3075cce98 100644 --- a/gcc/testsuite/g++.dg/cpp1z/decomp8.C +++ b/gcc/testsuite/g++.dg/cpp1z/decomp8.C @@ -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;