(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
debug/
ctf/
ctf-struct-array-1.c
       1  /* Test Compilation of mixed constructs containing structs and arrays.
       2  
       3     Further, the compiler is expected to generate a single CTF struct type for
       4     struct cmodel (due to Type de-duplication at the time of CTF generation).
       5     
       6     const qualifier in fields of structs should be processed.  It appears as a
       7     no-name CTF record with appropriate ctt_info.  In this testcase, there are
       8     two const qualifiers - const char and const struct cmodel.  However, due to
       9     way the debug information is represented in DWARF die, 3 const qualifier
      10     records appear in the CTF section.
      11  
      12     <1><e1>: Abbrev Number: 14 (DW_TAG_typedef)
      13        <e2>   DW_AT_name        : (indirect string, offset: 0x114): cmodel_t
      14        <e9>   DW_AT_type        : <0x9a>
      15     <1><ed>: Abbrev Number: 13 (DW_TAG_const_type)
      16        <ee>   DW_AT_type        : <0xe1>
      17     <1><f2>: Abbrev Number: 4 (DW_TAG_array_type)
      18        <f3>   DW_AT_type        : <0xed>
      19        <f7>   DW_AT_sibling     : <0x102>
      20  
      21     <2><101>: Abbrev Number: 0
      22     <1><102>: Abbrev Number: 13 (DW_TAG_const_type)
      23        <103>   DW_AT_type        : <0xf2>
      24     <1><107>: Abbrev Number: 15 (DW_TAG_variable)
      25        <108>   DW_AT_name        : (indirect string, offset: 0x57): _models
      26        <10f>   DW_AT_type        : <0x102>
      27     <1><11d>: Abbrev Number: 0
      28  
      29     This results in:
      30  
      31     _models ->  e: const const cmodel_t [3] (size 0x30) -> d: const cmodel_t [3] (size 0x30)
      32  
      33     Deemed as acceptable for now.  */
      34  
      35  /* { dg-do compile )  */
      36  /* { dg-options "-O0 -gctf -dA" } */
      37  
      38  /* { dg-final { scan-assembler-times "ascii \"cmodel.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
      39  /* { dg-final { scan-assembler-times "ascii \"cname.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
      40  /* { dg-final { scan-assembler-times "ascii \"cpointer.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
      41  /* { dg-final { scan-assembler-times "ascii \"cmodel_t.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
      42  
      43  /* 3 const records are expected.  */
      44  /* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 3 } } */
      45  
      46  struct a
      47  {
      48    int a1[2];
      49    struct { int b[3]; } a2;
      50  };
      51  
      52  struct a my_a;
      53  
      54  typedef struct cmodel
      55  {
      56    const char *cname;
      57    int ccode;
      58    int cpointer;
      59  } cmodel_t;
      60  
      61  static const cmodel_t _models[] = {
      62    {"ILP32", 0, 4},
      63    {"LP64", 0, 8},
      64    {"", 0, 0}
      65  };