1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
3f4a2713aSLionel Sambuc // rdar://11577384
4f4a2713aSLionel Sambuc // rdar://13423975
5f4a2713aSLionel Sambuc 
f(int i)6f4a2713aSLionel Sambuc int f(int i) {
7f4a2713aSLionel Sambuc   switch (i) {
8f4a2713aSLionel Sambuc     case 2147483647 + 2: // expected-warning {{overflow in expression; result is -2147483647 with type 'int'}}
9f4a2713aSLionel Sambuc       return 1;
10f4a2713aSLionel Sambuc     case 9223372036854775807L * 4: // expected-warning {{overflow in expression; result is -4 with type 'long'}}
11f4a2713aSLionel Sambuc       return 2;
12f4a2713aSLionel Sambuc     case (123456 *789012) + 1:  // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
13f4a2713aSLionel Sambuc       return 3;
14f4a2713aSLionel Sambuc     case (2147483647*4)/4: 	// expected-warning {{overflow in expression; result is -4 with type 'int'}}
15f4a2713aSLionel Sambuc     case (2147483647*4)%4: 	// expected-warning {{overflow in expression; result is -4 with type 'int'}}
16f4a2713aSLionel Sambuc       return 4;
17f4a2713aSLionel Sambuc     case 2147483647:
18f4a2713aSLionel Sambuc       return 0;
19f4a2713aSLionel Sambuc   }
20f4a2713aSLionel Sambuc   return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
21f4a2713aSLionel Sambuc 			     // expected-warning {{expression result unused}}
22f4a2713aSLionel Sambuc }
23*0a6a1f1dSLionel Sambuc 
24*0a6a1f1dSLionel Sambuc // rdar://18405357
25*0a6a1f1dSLionel Sambuc unsigned long long l = 65536 * 65536; // expected-warning {{overflow in expression; result is 0 with type 'int'}}
26*0a6a1f1dSLionel Sambuc unsigned long long l2 = 65536 * (unsigned)65536;
27*0a6a1f1dSLionel Sambuc unsigned long long l3 = 65536 * 65536ULL;
28