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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [scoped_enum.C] - Diff between revs 301 and 338

Only display areas with differences | Details | Blame | View Log

Rev 301 Rev 338
// { dg-options "-std=c++0x" }
// { dg-options "-std=c++0x" }
enum class Color1 {
enum class Color1 {
  Red,
  Red,
  Green,
  Green,
  Blue
  Blue
};
};
enum struct Color2 {
enum struct Color2 {
  Red, // { dg-error "previously declared here" }
  Red, // { dg-error "previously declared here" }
  Orange,
  Orange,
  Yellow,
  Yellow,
  Green,
  Green,
  Blue,
  Blue,
  Indigo = Green + 2,
  Indigo = Green + 2,
  Violet,
  Violet,
  Red // { dg-error "redefinition" }
  Red // { dg-error "redefinition" }
};
};
enum Color {
enum Color {
  Red, Green, Blue
  Red, Green, Blue
};
};
enum class Color3 {
enum class Color3 {
  Red
  Red
};
};
enum class Color color;
enum class Color color;
enum Color3 color3;
enum Color3 color3;
void f(int);
void f(int);
void f2(Color3);
void f2(Color3);
void g()
void g()
{
{
  int i = 0;
  int i = 0;
  f(color); // okay: unscoped enum
  f(color); // okay: unscoped enum
  f(color3); // { dg-error "cannot convert" }
  f(color3); // { dg-error "cannot convert" }
  f2(color); // { dg-error "cannot convert" }
  f2(color); // { dg-error "cannot convert" }
  f2(color3);
  f2(color3);
  f2(i);     // { dg-error "cannot convert" }
  f2(i);     // { dg-error "cannot convert" }
  i = color3; // { dg-error "cannot convert" }
  i = color3; // { dg-error "cannot convert" }
  color3 = i; // { dg-error "cannot convert" }
  color3 = i; // { dg-error "cannot convert" }
  f(static_cast(color3)); // okay
  f(static_cast(color3)); // okay
  int a[5];
  int a[5];
  a[color3]; // { dg-error "array subscript is not an integer" }
  a[color3]; // { dg-error "array subscript is not an integer" }
  bool b = color3; // { dg-error "cannot convert" }
  bool b = color3; // { dg-error "cannot convert" }
}
}
void h()
void h()
{
{
  Color1 c1 = Color1::Red;
  Color1 c1 = Color1::Red;
  Color2 c2 = Color1::Red; // { dg-error "cannot convert" }
  Color2 c2 = Color1::Red; // { dg-error "cannot convert" }
  c2 = Color1::Red; // { dg-error "cannot convert" }
  c2 = Color1::Red; // { dg-error "cannot convert" }
  c2 = Color2::Red;
  c2 = Color2::Red;
  int c3 = Color::Red;
  int c3 = Color::Red;
}
}
template
template
struct constant { };
struct constant { };
template
template
int& sfinae(constant*);
int& sfinae(constant*);
float& sfinae(void*);
float& sfinae(void*);
void sfinae_test()
void sfinae_test()
{
{
  int& test1 = sfinae((constant*)0);
  int& test1 = sfinae((constant*)0);
  int& test2 = sfinae((constant*)0);
  int& test2 = sfinae((constant*)0);
  float& test3 = sfinae((constant*)0);
  float& test3 = sfinae((constant*)0);
  int& test4 = sfinae((constant*)0);
  int& test4 = sfinae((constant*)0);
  float& test5 = sfinae((constant*)0);
  float& test5 = sfinae((constant*)0);
}
}
 
 

powered by: WebSVN 2.1.0

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