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