1  /* { dg-lto-do link } */
       2  /* { dg-lto-options { { -flto -O2 -Werror } } } */
       3  
       4  typedef __SIZE_TYPE__ size_t;
       5  typedef struct _IO_FILE FILE;
       6  
       7  #define STRING1(a) #a
       8  #define STRING2(a) STRING1(a)
       9  
      10  extern size_t fread (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ (STRING2(__USER_LABEL_PREFIX__) "fread")      __attribute__ ((__warn_unused_result__));
      11  extern size_t fread_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ (STRING2(__USER_LABEL_PREFIX__) "fread")      __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread called with bigger size * nmemb than length " "of destination buffer")));
      12  
      13  extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__))
      14  size_t
      15  local_fread (void *__restrict __ptr, size_t __size, size_t __n,
      16         FILE *__restrict __stream)
      17  {
      18    if (__builtin_object_size (__ptr, 0) != (size_t) -1)
      19      {
      20        if (!__builtin_constant_p (__size)
      21            || !__builtin_constant_p (__n)
      22            || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
      23          return fread (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
      24        if (__size * __n > __builtin_object_size (__ptr, 0))
      25          return fread_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
      26      }
      27  }
      28  
      29  volatile size_t nmemb;
      30  FILE *fp;
      31  int main ()
      32  {
      33    char file_contents[4096];
      34    /* We shouldn't get this resolved to a call to fread_warn.  */
      35    return local_fread (file_contents, 1, nmemb, fp);
      36  }