blob: 944048d1b2819b6d10f14751aeb73fdd981b5b2f [file] [log] [blame]
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +00001// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
2// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -triple x86_64-apple-darwin10 %s
3// rdar://11577384
Fariborz Jahanian2cd889d2013-03-15 16:36:04 +00004// rdar://13423975
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +00005
6int f(int i) {
7 switch (i) {
Fariborz Jahanian909df542013-01-25 17:47:49 +00008 case 2147483647 + 2: // expected-warning {{overflow in expression; result is -2147483647 with type 'int'}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +00009 return 1;
Fariborz Jahanian909df542013-01-25 17:47:49 +000010 case 9223372036854775807L * 4: // expected-warning {{overflow in expression; result is -4 with type 'long'}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000011 return 2;
Fariborz Jahanian909df542013-01-25 17:47:49 +000012 case (123456 *789012) + 1: // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
Fariborz Jahanianad48a502013-01-24 22:11:45 +000013 return 3;
Fariborz Jahanian2cd889d2013-03-15 16:36:04 +000014 case (2147483647*4)/4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
15 return 4;
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000016 case 2147483647:
17 return 0;
18 }
Fariborz Jahanian909df542013-01-25 17:47:49 +000019 return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
Fariborz Jahanian78c28be2013-01-25 17:19:07 +000020 // expected-warning {{expression result unused}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000021}