blob: ce1e7dc9433fed723674e9beda7a32d3d478f4a4 [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'}}
Fariborz Jahaniana30bab42013-03-15 17:03:56 +000015 case (2147483647*4)%4: // expected-warning {{overflow in expression; result is -4 with type 'int'}}
Fariborz Jahanian2cd889d2013-03-15 16:36:04 +000016 return 4;
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000017 case 2147483647:
18 return 0;
19 }
Fariborz Jahanian909df542013-01-25 17:47:49 +000020 return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
Fariborz Jahanian78c28be2013-01-25 17:19:07 +000021 // expected-warning {{expression result unused}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000022}