OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [range-for5.C] - Blame information for rev 715

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// Test for errors in range-based for loops
2
 
3
// { dg-do compile }
4
// { dg-options "-std=c++0x" }
5
 
6
struct container
7
{
8
};
9
 
10
int *begin(const container &c)
11
{
12
  return 0;
13
}
14
 
15
int end(const container &c) //Ops! wrong type
16
{
17
  return 0;
18
}
19
 
20
 
21
struct Implicit
22
{
23
  Implicit(int x)
24
  {}
25
};
26
struct Explicit
27
{
28
  explicit Explicit(int x)
29
  {}
30
};
31
 
32
void test1()
33
{
34
  container c;
35
  for (int x : c) // { dg-error "inconsistent|conversion" }
36
    ;
37
 
38
  int a[2] = {1,2};
39
  for (Implicit x : a)
40
    ;
41
  for (Explicit x : a) // { dg-error "conversion" }
42
    ;
43
  for (const Implicit &x : a)
44
    ;
45
  for (Implicit &&x : a)
46
    ;
47
 
48
  //Check the correct scopes
49
  int i;
50
  for (int i : a)               // { dg-error "previously declared" }
51
  {
52
    int i;                      // { dg-error "redeclaration" }
53
  }
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.