comparison gcc/testsuite/g++.dg/cpp1z/decomp10.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
comparison
equal deleted inserted replaced
111:04ced10e8804 131:84e7813d76e9
1 // { dg-options -std=c++17 } 1 // { dg-do compile { target c++17 } }
2 2
3 namespace std { 3 namespace std {
4 template<typename T> struct tuple_size; 4 template<typename T> struct tuple_size;
5 template<int, typename> struct tuple_element; 5 template<int, typename> struct tuple_element;
6 } 6 }
9 template<> struct std::tuple_size<A1> { }; 9 template<> struct std::tuple_size<A1> { };
10 void f1() { auto [ x ] = a1; } // { dg-error "is not an integral constant expression" } 10 void f1() { auto [ x ] = a1; } // { dg-error "is not an integral constant expression" }
11 11
12 struct A2 { int i,j; } a2; 12 struct A2 { int i,j; } a2;
13 template<> struct std::tuple_size<A2> { enum { value = 5 }; }; 13 template<> struct std::tuple_size<A2> { enum { value = 5 }; };
14 void f2() { auto [ x ] = a2; } // { dg-error "decomposes into 5" } 14 void f2() { auto [ x ] = a2; } // { dg-error "only 1 name provided" }
15 // { dg-message "decomposes into 5" "" { target *-*-* } .-1 }
15 16
16 struct A3 { int i,j; } a3; 17 struct A3 { int i,j; } a3;
17 template<> struct std::tuple_size<A3> { enum { value = 1 }; }; 18 template<> struct std::tuple_size<A3> { enum { value = 1 }; };
18 void f3() { auto [ x ] = a3; } // { dg-error "get" } 19 void f3() { auto [ x ] = a3; } // { dg-error "get" }
19 20
20 struct A3a { int i,j; int get(); } a3a; 21 struct A3a { int i,j; int get(); } a3a;
21 template<> struct std::tuple_size<A3a> { enum { value = 1 }; }; 22 template<> struct std::tuple_size<A3a> { enum { value = 1 }; };
22 void f3a() { auto [ x ] = a3a; } // { dg-error "get<0>" } 23 void f3a() { auto [ x ] = a3a; } // { dg-error "get" }
23 24
24 struct A3b { int i,j; } a3b; 25 struct A3b { int i,j; } a3b;
25 int get(A3b&&); 26 int get(A3b&&);
26 template<> struct std::tuple_size<A3b> { enum { value = 1 }; }; 27 template<> struct std::tuple_size<A3b> { enum { value = 1 }; };
27 void f3b() { auto [ x ] = a3b; } // { dg-error "get<0>" } 28 void f3b() { auto [ x ] = a3b; } // { dg-error "get<0>" }