blob: 4a5ded3b41ab117bea746c21285829a69ee1c965 [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 Jahanian78c28be2013-01-25 17:19:07 +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 Jahanian78c28be2013-01-25 17:19:07 +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 Jahanian78c28be2013-01-25 17:19:07 +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 Jahanian78c28be2013-01-25 17:19:07 +000016 return (i, 65537) * 65537; // expected-warning {{overflow in expression;result is 131073 with type 'int'}} \
17 // expected-warning {{expression result unused}}
Fariborz Jahaniana18e70b2013-01-09 23:04:56 +000018}