diff options
Diffstat (limited to 'gcc/testsuite/g++.dg/cpp0x/range-for20.C')
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/range-for20.C | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/cpp0x/range-for20.C b/gcc/testsuite/g++.dg/cpp0x/range-for20.C new file mode 100644 index 0000000000..890eb0aeaf --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/range-for20.C @@ -0,0 +1,36 @@ +// PR c++/49834 +// PR c++/50020 +// { dg-options -std=c++0x } + +struct A +{ + template <typename T> T get_value() const; +}; + +struct B { + A first, second; +}; + +struct C +{ + B* begin() const; + B* end() const; +}; + +template <typename Ret> +struct D +{ + Ret f(const C &p) + { + for (const B &i: p) // OK + i.second.get_value<int>(); + for (const auto &i: p) // ERROR + i.second.get_value<int>(); + return Ret(0); + } +}; + +void g() +{ + D<int>().f(C()); +} |