(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
debug/
ctf/
ctf-cvr-quals-1.c
       1  /* Test compilation of stubs with various qualifiers - const, restrict and
       2     volatile.
       3  
       4     Testcase includes a std header to allow testing of shared types across
       5     files.  Only one CTF record for int is expected.
       6     
       7     CTF records for CVR qualifiers are no-name records.  In this testcase, there
       8     are 5 qualifiers across constructs.  2 more no-name CTF records correspond to
       9     CTF pointer records.
      10  
      11      TYPEID: name string (size) -> ref TYPEID : ref name string (size) -> ...
      12  
      13     Types:
      14        1: long int (size 0x8)
      15        2: long unsigned int (size 0x8)
      16        3: size_t (size 0x8) -> 2: long unsigned int (size 0x8)
      17        4: int (size 0x4)
      18        5: const int (size 0x4) -> 4: int (size 0x4)
      19        6: volatile const int (size 0x4) -> 5: const int (size 0x4) -> 4: int (size 0x4)
      20        7: long long int (size 0x8)
      21        8: long double (size 0x10)
      22        9: int * (size 0x8) -> 4: int (size 0x4)
      23        a: int *restrict (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
      24        b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
      25        c: const int *restrict (size 0x8) -> b: const int * (size 0x8) -> 5: const int (size 0x4) -> 4: int (size 0x4)
      26        d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
      27        e: const INTP (size 0x8) -> d: INTP (size 0x8) -> 9: int * (size 0x8) -> 4: int (size 0x4)
      28        f: void (size 0x0)
      29        10: void (*) (size_t, int *restrict, const int *restrict) (size 0x0)
      30      */
      31  
      32  /* { dg-do compile )  */
      33  /* { dg-options "-O0 -gctf -dA" } */
      34  /* { dg-options "-O0 -gctf -gdwarf-4 -dA" { target { *-*-darwin* } } } */
      35  
      36  /* { dg-final { scan-assembler-times "ascii \"int.0\"\[\t \]+\[^\n\]*ctf_string" 1 } } */
      37  /* { dg-final { scan-assembler-times "\[\t \]0\[\t \]+\[^\n\]*ctt_name" 7 } } */
      38  
      39  /* type id 9, b have POINTER type.  */
      40  /* { dg-final { scan-assembler-times "\[\t \]0xe000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
      41  
      42  /* type id 5, e have CONST qualifier.  */
      43  /* { dg-final { scan-assembler-times "\[\t \]0x32000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
      44  
      45  /* type id a, c have RESTRICT qualifier.  */
      46  /* { dg-final { scan-assembler-times "\[\t \]0x36000000\[\t \]+\[^\n\]*ctt_info" 2 } } */
      47  
      48  /* type id 6 has VOLATILE qualifier.  */
      49  /* { dg-final { scan-assembler-times "\[\t \]0x2e000000\[\t \]+\[^\n\]*ctt_info" 1 } } */
      50  
      51  #include "stddef.h"
      52  
      53  const volatile int a = 5;
      54  int *restrict b;
      55  
      56  const int * i;
      57  int const * j;
      58  
      59  typedef int * INTP;
      60  const INTP int_p;
      61  
      62  void foo (size_t n, int *restrict p, const int *restrict q)
      63  {
      64    while (n-- > 0)
      65      *p++ = *q++;
      66  }