blob: 82ce6747a3a4910766bd80c075564d79fe57109e [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
4
5int f(int i) {
6 switch (i) {
Fariborz Jahanian909df542013-01-25 17:47:49 +00007 case 2147483647 + 2: // expected-warning {{overflow in expression; result is -2147483647 with type 'int'}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +00008 return 1;
Fariborz Jahanian909df542013-01-25 17:47:49 +00009 case 9223372036854775807L * 4: // expected-warning {{overflow in expression; result is -4 with type 'long'}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000010 return 2;
Fariborz Jahanian909df542013-01-25 17:47:49 +000011 case (123456 *789012) + 1: // expected-warning {{overflow in expression; result is -1375982336 with type 'int'}}
Fariborz Jahanianad48a502013-01-24 22:11:45 +000012 return 3;
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000013 case 2147483647:
14 return 0;
15 }
Fariborz Jahanian909df542013-01-25 17:47:49 +000016 return (i, 65537) * 65537; // expected-warning {{overflow in expression; result is 131073 with type 'int'}} \
Fariborz Jahanian78c28be2013-01-25 17:19:07 +000017 // expected-warning {{expression result unused}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000018}