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)));
9 test_passthrough (const char* str
)
11 return example_fn (str
);
17 return example_fn (NULL
); /* { dg-warning "use of NULL where non-null expected" } */
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 } */
29 test_uninitialized_str (void)
32 return example_fn (str
); /* { dg-warning "use of uninitialized value 'str\\\[0\\\]'" } */