1  /* PR tree-optimization/85259 - Missing -Wstringop-overflow= since r256683
       2     { dg-do compile }
       3     { dg-options "-O2 -Wstringop-overflow -ftrack-macro-expansion=0" } */
       4  
       5  #define bos1(p) __builtin_object_size (p, 1)
       6  #define strcat(d, s) __builtin___strcat_chk (d, s, bos1 (d))
       7  #define strcpy(d, s) __builtin___strcpy_chk (d, s, bos1 (d))
       8  
       9  char a1[1];
      10  char a2[2];
      11  char a3[3];
      12  char a4[4];
      13  char a5[5];
      14  char a6[6];
      15  char a7[7];
      16  char a8[8];
      17  
      18  /* Verify that at least one instance of -Wstringop-overflow is issued
      19     for each pair of strcpy/strcat calls.  */
      20  
      21  void test_strcpy_strcat_1 (void)
      22  {
      23    strcpy (a1, "1"), strcat (a1, "2");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      24  }
      25  
      26  void test_strcpy_strcat_2 (void)
      27  {
      28    strcpy (a2, "12"), strcat (a2, "3");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      29  }
      30  
      31  void test_strcpy_strcat_3 (void)
      32  {
      33    strcpy (a3, "123"), strcat (a3, "4");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      34  }
      35  
      36  void test_strcpy_strcat_4 (void)
      37  {
      38    strcpy (a4, "1234"), strcat (a4, "5");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      39  }
      40  
      41  void test_strcpy_strcat_5 (void)
      42  {
      43    strcpy (a5, "12345"), strcat (a5, "6");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      44  }
      45  
      46  void test_strcpy_strcat_6 (void)
      47  {
      48    strcpy (a6, "123456"), strcat (a6, "7");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      49  }
      50  
      51  void test_strcpy_strcat_7 (void)
      52  {
      53    strcpy (a7, "1234567"), strcat (a7, "8");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      54  }
      55  
      56  void test_strcpy_strcat_8 (void)
      57  {
      58    strcpy (a8, "12345678"), strcat (a8, "9");   /* { dg-warning "\\\[-Wstringop-overflow=]" } */
      59  }