| 1 |
/* { dg-additional-options "-Wno-analyzer-too-complex -Wno-analyzer-symbol-too-complex" } */ |
| 2 |
|
| 3 |
#include "../../gcc.dg/analyzer/analyzer-decls.h" |
| 4 |
|
| 5 |
extern char *strtok (char *str, const char *delim); |
| 6 |
|
| 7 |
void test (void) |
| 8 |
{ |
| 9 |
char buffer[] = { 'a', 'x', 'b', 'y', 'c', '\0' }; |
| 10 |
|
| 11 |
char *p1 = strtok (buffer, "x"); |
| 12 |
/* Should result in: |
| 13 |
| buffer[] = { 'a', '\0', 'b', 'y', 'c', '\0' }, |
| 14 |
| ^ ^ ^ |
| 15 |
| | | | |
| 16 |
| | | internal ptr |
| 17 |
| p1 modified. */ |
| 18 |
|
| 19 |
char *p2 = strtok (NULL, "y"); /* note new delimiter. */ |
| 20 |
/* Should result in: |
| 21 |
| buffer[] = { 'a', '\0', 'b', '\0', 'c', '\0' }, |
| 22 |
| ^ ^ ^ |
| 23 |
| | | | |
| 24 |
| | | internal ptr |
| 25 |
| p2 modified. */ |
| 26 |
|
| 27 |
char *p3 = strtok (NULL, "z"); /* again new delimiter. */ |
| 28 |
/* Should result in: |
| 29 |
| buffer[] = { 'a', '\0', 'b', '\0', 'c', '\0' }, |
| 30 |
| ^ ^~ |
| 31 |
| | | |
| 32 |
| | internal ptr |
| 33 |
| p3. */ |
| 34 |
|
| 35 |
char *p4 = strtok (NULL, "z"); |
| 36 |
/* Should result in p4 == NULL, and: |
| 37 |
| buffer[] = { 'a', '\0', 'b', '\0', 'c', '\0' }, |
| 38 |
| ^~ |
| 39 |
| | |
| 40 |
| internal ptr. */ |
| 41 |
|
| 42 |
/* We don't yet model strtok closely enough to capture |
| 43 |
these exact behaviors. */ |
| 44 |
} |