Mercurial > hg > CbC > CbC_gcc
view gcc/testsuite/gcc.dg/analyzer/strcmp-1.c @ 152:2b5abeee2509
update gcc11
author | anatofuz |
---|---|
date | Mon, 25 May 2020 07:50:57 +0900 |
parents | 1830386684a0 |
children |
line wrap: on
line source
/* Verify that we clarify the sense of paths involving strcmp. */ #include <string.h> #include <stdlib.h> int test_1 (const char *str, char *ptr) { if (strcmp (str, "VALUE")) /* { dg-message "following 'true' branch \\(when the strings are non-equal\\)\\.\\.\\." } */ free (ptr); free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ } int test_2 (const char *str, char *ptr) { if (strcmp (str, "VALUE") == 0) /* { dg-message "following 'true' branch \\(when the strings are equal\\)\\.\\.\\." } */ free (ptr); free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ } int test_3 (const char *str, char *ptr) { if (!strcmp (str, "VALUE")) /* { dg-message "following 'true' branch \\(when the strings are equal\\)\\.\\.\\." } */ free (ptr); free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ } int test_4 (const char *str, char *ptr) { if (strcmp (str, "VALUE")) /* { dg-message "following 'false' branch \\(when the strings are equal\\)\\.\\.\\." } */ { } else free (ptr); free (ptr); /* { dg-warning "double-'free' of 'ptr'" } */ }