This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] SOme further g++.dg/cpp1z/decomp*.C tests
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 15 Nov 2016 12:04:55 -0500
- Subject: Re: [C++ PATCH] SOme further g++.dg/cpp1z/decomp*.C tests
- Authentication-results: sourceware.org; auth=none
- References: <20161115141344.GG3541@tucnak.redhat.com>
OK.
On Tue, Nov 15, 2016 at 9:13 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This patch adds 3 new tests. Tested on x86_64-linux, ok for trunk?
>
> 2016-11-15 Jakub Jelinek <jakub@redhat.com>
>
> * g++.dg/cpp1z/decomp13.C: New test.
> * g++.dg/cpp1z/decomp14.C: New test.
> * g++.dg/cpp1z/decomp15.C: New test.
>
> --- gcc/testsuite/g++.dg/cpp1z/decomp13.C.jj 2016-11-15 14:25:18.902048735 +0100
> +++ gcc/testsuite/g++.dg/cpp1z/decomp13.C 2016-11-15 14:48:12.795463351 +0100
> @@ -0,0 +1,30 @@
> +// { dg-do compile { target c++11 } }
> +// { dg-options "" }
> +
> +struct A { int f; };
> +struct B { int b; };
> +struct C : virtual A {};
> +struct D : virtual A {};
> +struct E { int f; };
> +struct F : A { int f; };
> +struct G : A, E {};
> +struct H : C, D {};
> +struct I : A, C {}; // { dg-warning "due to ambiguity" }
> +struct J : B {};
> +struct K : B, virtual J {}; // { dg-warning "due to ambiguity" }
> +struct L : virtual J {};
> +struct M : virtual J, L {};
> +
> +void
> +foo (C &c, F &f, G &g, H &h, I &i, K &k, M &m)
> +{
> + auto [ ci ] = c; // { dg-warning "decomposition declaration 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 }
> + 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 } }
> + 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 } }
> +}
> --- gcc/testsuite/g++.dg/cpp1z/decomp14.C.jj 2016-11-15 14:30:40.296941834 +0100
> +++ gcc/testsuite/g++.dg/cpp1z/decomp14.C 2016-11-15 14:50:32.361678491 +0100
> @@ -0,0 +1,24 @@
> +// { dg-do compile }
> +// { dg-options "-std=c++1z" }
> +
> +struct A { bool a, b; };
> +struct B { int a, b; };
> +
> +void
> +foo ()
> +{
> + auto [ a, b ] = A ();
> + for (auto [ a, b ] = A (); a; )
> + ;
> + if (auto [ a, b ] = A (); a)
> + ;
> + switch (auto [ a, b ] = B (); b)
> + {
> + case 2:
> + break;
> + }
> + auto && [ c, d ] = A ();
> + [[maybe_unused]] auto [ e, f ] = A ();
> + alignas (A) auto [ g, h ] = A ();
> + __attribute__((unused)) auto [ i, j ] = A ();
> +}
> --- gcc/testsuite/g++.dg/cpp1z/decomp15.C.jj 2016-11-15 14:38:55.198602649 +0100
> +++ gcc/testsuite/g++.dg/cpp1z/decomp15.C 2016-11-15 14:46:33.000000000 +0100
> @@ -0,0 +1,47 @@
> +// { dg-do compile }
> +// { dg-options "-std=c++1z" }
> +
> +struct A { bool a, b; };
> +struct B { int a, b; };
> +
> +void
> +foo ()
> +{
> + auto [ a, b ] = A ();
> + for (; auto [ a, b ] = A (); ) // { dg-error "expected" }
> + ;
> + for (; false; auto [ a, b ] = A ()) // { dg-error "expected" }
> + ;
> + if (auto [ a, b ] = A ()) // { dg-error "expected" }
> + ;
> + if (auto [ a, b ] = A (); auto [ c, d ] = A ()) // { dg-error "expected" }
> + ;
> + if (int d = 5; auto [ a, b ] = A ()) // { dg-error "expected" }
> + ;
> + switch (auto [ a, b ] = B ()) // { dg-error "expected" }
> + {
> + case 2:
> + break;
> + }
> + switch (int d = 5; auto [ a, b ] = B ()) // { dg-error "expected" }
> + {
> + case 2:
> + break;
> + }
> + A e = A ();
> + auto && [ c, d ] = e;
> + auto [ i, j ] = A (), [ k, l ] = A (); // { dg-error "expected" }
> + auto m = A (), [ n, o ] = A (); // { dg-error "expected" }
> +}
> +
> +template <typename T>
> +auto [ a, b ] = A (); // { dg-error "expected" }
> +
> +struct C
> +{
> + auto [ e, f ] = A (); // { dg-error "expected" }
> + mutable auto [ g, h ] = A (); // { dg-error "expected" }
> + virtual auto [ i, j ] = A (); // { dg-error "expected" }
> + explicit auto [ k, l ] = A (); // { dg-error "expected" }
> + friend auto [ m, n ] = A (); // { dg-error "expected" }
> +};
>
> Jakub