xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/casts.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store=region -verify %s
2f4a2713aSLionel Sambuc 
PR14634(int x)3f4a2713aSLionel Sambuc bool PR14634(int x) {
4f4a2713aSLionel Sambuc   double y = (double)x;
5f4a2713aSLionel Sambuc   return !y;
6f4a2713aSLionel Sambuc }
7f4a2713aSLionel Sambuc 
PR14634_implicit(int x)8f4a2713aSLionel Sambuc bool PR14634_implicit(int x) {
9f4a2713aSLionel Sambuc   double y = (double)x;
10f4a2713aSLionel Sambuc   return y;
11f4a2713aSLionel Sambuc }
12*0a6a1f1dSLionel Sambuc 
intAsBoolAsSwitchCondition(int c)13*0a6a1f1dSLionel Sambuc void intAsBoolAsSwitchCondition(int c) {
14*0a6a1f1dSLionel Sambuc   switch ((bool)c) { // expected-warning {{switch condition has boolean value}}
15*0a6a1f1dSLionel Sambuc   case 0:
16*0a6a1f1dSLionel Sambuc     break;
17*0a6a1f1dSLionel Sambuc   }
18*0a6a1f1dSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc   switch ((int)(bool)c) { // no-warning
20*0a6a1f1dSLionel Sambuc     case 0:
21*0a6a1f1dSLionel Sambuc       break;
22*0a6a1f1dSLionel Sambuc   }
23*0a6a1f1dSLionel Sambuc }
24