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/] [warn/] [pr12242.C] - Diff between revs 301 and 338

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

Rev 301 Rev 338
// PR 12242: should warn about out-of-range int->enum conversions
// PR 12242: should warn about out-of-range int->enum conversions
// { dg-do compile }
// { dg-do compile }
// { dg-options "-Wconversion -fpermissive" }
// { dg-options "-Wconversion -fpermissive" }
enum X { A };
enum X { A };
enum Y { B, C, D };
enum Y { B, C, D };
void example ()
void example ()
{
{
  int i = 5;
  int i = 5;
  X x;
  X x;
  Y y;
  Y y;
  x = 10;  // { dg-warning "invalid conversion from .int. to .X." }
  x = 10;  // { dg-warning "invalid conversion from .int. to .X." }
           // { dg-warning "unspecified" "" { target *-*-* } 13 }
           // { dg-warning "unspecified" "" { target *-*-* } 13 }
  x = 1;   // { dg-warning "invalid conversion from .int. to .X." }
  x = 1;   // { dg-warning "invalid conversion from .int. to .X." }
  x = C;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  x = C;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  x = D;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  x = D;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  y = A;   // { dg-error "cannot convert .X. to .Y. in assignment" }
  y = A;   // { dg-error "cannot convert .X. to .Y. in assignment" }
  x = y;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  x = y;   // { dg-error "cannot convert .Y. to .X. in assignment" }
  x = i;   // { dg-warning "invalid conversion from .int. to .X."  }
  x = i;   // { dg-warning "invalid conversion from .int. to .X."  }
}
}
void foo ()
void foo ()
{
{
  X a = static_cast (10); // { dg-warning "unspecified" }
  X a = static_cast (10); // { dg-warning "unspecified" }
  X b = static_cast (0);
  X b = static_cast (0);
  X c = static_cast (1);
  X c = static_cast (1);
  X d = static_cast (2); // { dg-warning "unspecified" }
  X d = static_cast (2); // { dg-warning "unspecified" }
  X f = static_cast ((int)A);
  X f = static_cast ((int)A);
  X g = static_cast (B);
  X g = static_cast (B);
  X h = static_cast (C);
  X h = static_cast (C);
  X e = static_cast (D); // { dg-warning "unspecified" }
  X e = static_cast (D); // { dg-warning "unspecified" }
}
}
enum QEvent { x = 42 };
enum QEvent { x = 42 };
int bar()
int bar()
{
{
  QEvent x = ( QEvent ) 42000; // { dg-warning "unspecified" }
  QEvent x = ( QEvent ) 42000; // { dg-warning "unspecified" }
  return ( int ) x;
  return ( int ) x;
}
}
enum W {a,b,c};
enum W {a,b,c};
enum Z {d,e,f,g};
enum Z {d,e,f,g};
void bazz (int, int, int, int);
void bazz (int, int, int, int);
void baz() {
void baz() {
  int three = 3;
  int three = 3;
  int four = 4;
  int four = 4;
  bazz (
  bazz (
        W(three),
        W(three),
        W(3),
        W(3),
        Z(four),
        Z(four),
        Z(4) // { dg-warning "unspecified" }
        Z(4) // { dg-warning "unspecified" }
        );
        );
}
}
 
 

powered by: WebSVN 2.1.0

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