| 1 |
/* Verify that we correctly consolidate conditionals in paths. */ |
| 2 |
|
| 3 |
#include "analyzer-decls.h" |
| 4 |
|
| 5 |
extern int foo (); |
| 6 |
extern int bar (); |
| 7 |
extern int baz (); |
| 8 |
|
| 9 |
void test_1 (int a, int b, int c) |
| 10 |
{ |
| 11 |
if (a && b && c) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ |
| 12 |
__analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 13 |
} |
| 14 |
|
| 15 |
void test_2 (int a, int b, int c) |
| 16 |
{ |
| 17 |
if (a && b) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ |
| 18 |
if (c) /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 19 |
__analyzer_dump_path (); |
| 20 |
} |
| 21 |
|
| 22 |
void test_3 (int a, int b, int c) |
| 23 |
{ |
| 24 |
if (a) /* { dg-message "\\(1\\) following 'true' branch" } */ |
| 25 |
if (b && c) /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 26 |
__analyzer_dump_path (); |
| 27 |
} |
| 28 |
|
| 29 |
void test_4 (void) |
| 30 |
{ |
| 31 |
while (foo () && bar ()) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ |
| 32 |
__analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 33 |
} |
| 34 |
|
| 35 |
void test_5 (int a, int b, int c) |
| 36 |
{ |
| 37 |
if (a || b || c) /* { dg-message "\\(1\\) following 'false' branch\\.\\.\\." } */ |
| 38 |
{ |
| 39 |
} |
| 40 |
else |
| 41 |
__analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 42 |
} |
| 43 |
|
| 44 |
void test_6 (void) |
| 45 |
{ |
| 46 |
int i; |
| 47 |
for (i = 0; i < 10 && foo (); i++) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ |
| 48 |
__analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 49 |
} |
| 50 |
|
| 51 |
int test_7 (void) |
| 52 |
{ |
| 53 |
if (foo () ? bar () ? baz () : 0 : 0) /* { dg-message "\\(1\\) following 'true' branch\\.\\.\\." } */ |
| 54 |
__analyzer_dump_path (); /* { dg-message "\\(2\\) \\.\\.\\.to here" } */ |
| 55 |
} |