middle-end: Fix stalled swapped condition code value [PR115836]
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / deref-before-check-pr114408.c
blobd55720271d0f283b2fc507669c278082346557e3
1 extern void unknown_returns (const char *p);
2 extern void unknown_noreturn (const char *p) __attribute__((__noreturn__));
4 void test_1 (const char *p)
6 if (p)
7 unknown_returns (p);
8 __builtin_strcmp ("a", p); /* { dg-message "pointer 'p' is dereferenced here" "" { target c } } */
9 if (p) /* { dg-warning "check of 'p' for NULL after already dereferencing it" "" { target c } } */
10 unknown_returns (p);
11 __builtin_strcmp ("a", p);
14 void test_2 (const char *p)
16 if (p)
17 unknown_noreturn (p);
18 __builtin_strcmp ("a", p);
19 if (p) /* { dg-bogus "check of 'p' for NULL after already dereferencing it" } */
20 unknown_noreturn (p);
21 __builtin_strcmp ("a", p);