Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/g++.dg/cpp0x/range-for5.C @ 158:494b0b89df80 default tip
...
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 18:13:55 +0900 |
parents | 04ced10e8804 |
children |
line wrap: on
line source
// Test for errors in range-based for loops // { dg-do compile { target c++11 } } struct container { }; int *begin(const container &c) { return 0; } int end(const container &c) //Ops! wrong type { return 0; } struct Implicit { Implicit(int x) {} }; struct Explicit { explicit Explicit(int x) {} }; void test1() { container c; for (int x : c) // { dg-error "inconsistent|conversion|comparison" } ; int a[2] = {1,2}; for (Implicit x : a) ; for (Explicit x : a) // { dg-error "conversion" } ; for (const Implicit &x : a) ; for (Implicit &&x : a) ; //Check the correct scopes int i; for (int i : a) // { dg-message "previously declared" } { int i; // { dg-error "redeclaration" } } }