| 1 |
#include "../../gcc.dg/analyzer/analyzer-decls.h" |
| 2 |
|
| 3 |
extern char *strtok (char *str, const char *delim) |
| 4 |
__attribute__((nonnull (2))); |
| 5 |
|
| 6 |
int |
| 7 |
main (int argc, char *argv[]) |
| 8 |
{ |
| 9 |
char *cmd; |
| 10 |
char *arg; |
| 11 |
|
| 12 |
if (argc < 2) |
| 13 |
return -1; |
| 14 |
|
| 15 |
cmd = strtok (NULL, " "); /* { dg-line "first_call" } */ |
| 16 |
arg = strtok (NULL, " "); |
| 17 |
return 0; |
| 18 |
|
| 19 |
/* C: |
| 20 |
{ dg-warning "calling 'strtok' for first time with NULL as argument 1 has undefined behavior \\\[CWE-476\\\] \\\[-Wanalyzer-undefined-behavior-strtok\\\]" "" { target c } first_call } |
| 21 |
{ dg-message "some implementations of 'strtok' may crash on such input" "" { target c } first_call } */ |
| 22 |
|
| 23 |
/* C++: |
| 24 |
{ dg-warning "calling 'char\\* strtok\\(char\\*, const char\\*\\)' for first time with NULL as argument 1 has undefined behavior \\\[CWE-476\\\] \\\[-Wanalyzer-undefined-behavior-strtok\\\]" "" { target c++ } first_call } |
| 25 |
{ dg-message "some implementations of 'char\\* strtok\\(char\\*, const char\\*\\)' may crash on such input" "" { target c++ } first_call } */ |
| 26 |
} |