Skip several analyzer socket tests on hppa*-*-hpux*
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / attr-null_terminated_string_arg-nonnull-2.c
blob2614633318ecbf8ead7a573bcd1035c577f2463a
1 /* { dg-additional-options "-fpermissive" { target c++ } } */
3 #include "../../gcc.dg/analyzer/analyzer-decls.h"
5 extern char *example_fn (const char *p) /* { dg-message "argument 1 of '\[^\n\r\]*' must be a pointer to a null-terminated string" } */
6 __attribute__((null_terminated_string_arg (1), nonnull (1)));
8 char *
9 test_passthrough (const char* str)
11 return example_fn (str);
14 char *
15 test_NULL_str (void)
17 return example_fn (NULL); /* { dg-warning "use of NULL where non-null expected" } */
20 char *
21 test_unterminated_str (void)
23 char str[3] = "abc"; /* { dg-warning "initializer-string for '\[^\n\]*' is too long" "" { target c++ } } */
24 return example_fn (str); /* { dg-warning "stack-based buffer over-read" } */
25 /* { dg-message "while looking for null terminator for argument 1" "note" { target *-*-* } .-1 } */
28 char *
29 test_uninitialized_str (void)
31 char str[16];
32 return example_fn (str); /* { dg-warning "use of uninitialized value 'str\\\[0\\\]'" } */