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] - Rev 774

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

// Test for errors in range-based for loops

// { dg-do compile }
// { dg-options "-std=c++0x" }

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" }
    ;

  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-error "previously declared" }
  {
    int i;                      // { dg-error "redeclaration" }
  }
}

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

powered by: WebSVN 2.1.0

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