(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
format/
attr-5.c
       1  /* Test for format attributes: test default attributes are silently ignored
       2     when a function is redeclared in an inappropriate manner.  */
       3  /* Origin: Joseph Myers <jsm28@cam.ac.uk> */
       4  /* { dg-do compile } */
       5  /* { dg-options "-std=gnu99 -Wformat" } */
       6  
       7  /* We can't #include "format.h" here.  */
       8  
       9  /* This scanf declaration is static, so can't be the system function.  */
      10  static int scanf(const char *restrict, ...);
      11  
      12  /* This sscanf declaration doesn't have variable arguments, so isn't
      13     compatible with a format attribute.  */
      14  extern int sscanf(const char *restrict, const char *restrict, int *); /* { dg-warning "conflict" "conflict" } */
      15  
      16  void
      17  foo (const char *s, int *p)
      18  {
      19    scanf("%ld", p); /* { dg-bogus "format" "static" } */
      20    sscanf(s, "%ld", p); /* { dg-bogus "format" "wrong type" } */
      21  }
      22  
      23  /* Dummy definition of scanf.  */
      24  static int
      25  scanf (const char *restrict fmt, ...)
      26  {
      27    return 0;
      28  }