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