* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / range-for14.C
blob4e0333cf927e52f6d78635ab41f77fd44e4f3d1f
1 // Test for other range-based for loops with
2 // begin/end member functions
4 // { dg-do compile { target c++11 } }
6 //These should not be used
7 template<typename T> int *begin(T &t)
9     T::fail;
10     return 0;
12 template<typename T> int *end(T &t)
14     T::fail;
15     return 0;
18 //Test for defaults
20 struct default1
22     int *begin(int x); // { dg-message "note" }
23     int *end();
26 struct default2
28     int *begin(int x=0);
29     int *end();
32 struct default3
34     template <typename T> T *begin(); // { dg-message "note" }
35     int *end();
38 struct default4
40     template <typename T=int> T *begin();
41     int *end();
44 struct default5
46     template <typename T=int> T *begin(int x=0);
47     int *end();
50 void test1()
52   for (int x : default1()); // { dg-error "no matching function|note" }
53   for (int x : default2());
54   for (int x : default3()); // { dg-error "no matching function|note" }
55   for (int x : default4());
56   for (int x : default5());
59 //Inheritance tests
61 struct base_begin
63     int *begin(); // { dg-message "" }
66 struct base_end
68     int *end();
71 struct derived1 : base_begin, base_end
75 struct base_begin2 : base_begin
79 struct derived2 : base_begin, base_end, base_begin2 // { dg-warning "" }
83 struct base_begin3 : virtual base_begin
87 struct derived3 : virtual base_begin, base_end, base_begin3
91 void test2()
93   for (int x : derived1());
94   for (int x : derived2()); // { dg-error "is ambiguous" }
95   for (int x : derived3());