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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [warn/] [Wswitch-2.C] - Blame information for rev 318

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

Line No. Rev Author Line
1 301 jeremybenn
/* Further -Wswitch tests.  */
2
/* { dg-do compile } */
3
/* { dg-options "-Wswitch" } */
4
 
5
enum e { e1 = 0, e2 = 1, e3 = 1, e4 = 2 };
6
 
7
int
8
foo (enum e ei, int j)
9
{
10
  switch (ei)
11
    {
12
    case e1: return 1;
13
    case e3: return 2;
14
    case e4: return 3;
15
    }   /* No warning here since e2 has the same value as e3.  */
16
  switch (ei) /* { dg-warning "enumeration value 'e4' not handled in switch" "enum e4" } */
17
    {
18
    case e1: return 1;
19
    case e2: return 2;
20
    }
21
  switch ((int) ei)
22
    {
23
    case e1: return 1;
24
    }   /* No warning here since switch condition was cast to int.  */
25
  switch ((enum e) j) /* { dg-warning "enumeration value 'e1' not handled in switch" "enum e1" } */
26
    {
27
    case e2: return 1;
28
    case e4: return 2;
29
    }
30
  return 0;
31
}

powered by: WebSVN 2.1.0

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