aboutsummaryrefslogtreecommitdiff
path: root/test/Sema/switch-1.c
blob: e029bc9ffbfedb6c9ececcaed74e97df5d371c6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
// rdar://11577384

int f(int i) {
  switch (i) {
    case 2147483647 + 2: // expected-note {{value 2147483649 is outside the range of representable values of type 'int'}}  \
                      // expected-warning {{overflow in case constant expression results in value -2147483647}} 
      return 1;
    case 9223372036854775807L * 4 : // expected-note {{value 36893488147419103228 is outside the range of representable values of type 'long'}}   \
                        // expected-warning {{overflow in case constant expression results in value -4}} 
      return 2;
    case 2147483647:
      return 0;
  }
  return 0;
}