1 /* Verify that deduplication of -Wanalyzer-write-to-string-literal (and their
4 /* { dg-additional-options "-fanalyzer-show-duplicate-count" } */
5 /* { dg-require-effective-target alloca } */
7 #include "../../gcc.dg/analyzer/analyzer-decls.h"
9 typedef __SIZE_TYPE__
size_t;
11 int getrandom (void *__buffer
, size_t __length
,
12 /* { dg-message "parameter 1 of 'getrandom' marked with attribute 'access \\(write_only, 1, 2\\)'" "" { target c } .-1 } */
13 /* { dg-message "parameter 1 of 'int getrandom\\(void\\*, size_t, unsigned int\\)' marked with attribute 'access \\(write_only, 1, 2\\)'" "" { target c++ } .-2 } */
15 __attribute__ ((access (__write_only__
, 1, 2)));
17 #define GRND_RANDOM 0x02
23 ptr
= (char *) __builtin_malloc (1024);
25 ptr
= (char *) __builtin_alloca (1024);
27 __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */
29 if (getrandom((char *)"foo", 3, GRND_RANDOM
)) /* { dg-warning "write to string literal" "warning" } */
30 /* { dg-message "1 duplicate" "dup" { target *-*-* } .-1 } */
31 __builtin_printf("ok\n");