(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.dg/
pointer-array-atomic.c
       1  /* { dg-do compile } */
       2  /* { dg-options "-std=c11" } */
       3  /* Origin: Martin Uecker <uecker@eecs.berkeley.edu> */
       4  void tvoid(void* x);
       5  void transpose0(double* out, _Atomic double* in) { }
       6  void transpose1(double out[2][2], _Atomic double in[2][2]) { }
       7  void transpose2(double out[2][2][2], _Atomic double in[2][2][2]) { }
       8  // return
       9  int (*x2(_Atomic int x[3][3]))[3] { return x; } /* { dg-warning "returning '_Atomic int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */
      10  _Atomic int (*x3(int x[3][3]))[3] { return x; } /* { dg-warning "returning 'int \\(\\*\\)\\\[3\\\]' from a function with incompatible return type" } */
      11  void test(void)
      12  {
      13  	double x0[2];
      14  	double y0[2];
      15  	_Atomic double z0[4];
      16  	double x1[2][2];
      17  	double y1[2][2];
      18  	double o1[2][3];
      19  	_Atomic double z1[2][2];
      20  	double x2[2][2][2];
      21  	double y2[2][2][2];
      22  	double o2[2][2][3];
      23  	_Atomic double z2[2][2][2];
      24  	tvoid(z0);
      25  	tvoid(z1);
      26  	tvoid(z2);
      27  	// passing as arguments
      28  	transpose0(y0, x0); /* { dg-warning "passing argument 2 of 'transpose0' from incompatible pointer type" } */
      29  	transpose1(y1, o1); /* { dg-warning "passing argument 2 of 'transpose1' from incompatible pointer type" } */
      30  	transpose1(y1, x1); /* { dg-warning "passing argument 2 of 'transpose1' from incompatible pointer type" } */
      31  	transpose2(y2, o2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */
      32  	transpose2(y2, x2); /* { dg-warning "passing argument 2 of 'transpose2' from incompatible pointer type" } */
      33  	// initialization
      34  	_Atomic double (*x0p) = x0; /* { dg-warning "initialization of '_Atomic double \\*' from incompatible pointer type" } */
      35  	_Atomic double (*x1p)[2] = x1; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */
      36  	_Atomic double (*x2p)[2][2] = x2; /* { dg-warning "initialization of '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */
      37  	// assignment
      38  	x0p = x0; /* { dg-warning "assignment to '_Atomic double \\*' from incompatible pointer type" } */
      39  	x1p = x1; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]' from incompatible pointer type" } */
      40  	x2p = x2; /* { dg-warning "assignment to '_Atomic double \\(\\*\\)\\\[2\\\]\\\[2\\\]' from incompatible pointer type" } */
      41  	// subtraction
      42  	&(x0[1]) - &(z0[0]); /* { dg-error "invalid operands to binary" } */
      43  	&(x1[1]) - &(z1[0]); /* { dg-error "invalid operands to binary" } */
      44  	&(x2[1]) - &(z2[0]); /* { dg-error "invalid operands to binary" } */
      45  	// comparison
      46  	x0 == z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      47  	x1 == z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      48  	x2 == z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      49  	x0 > z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      50  	x1 > z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      51  	x2 > z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      52  	x0 < z0; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      53  	x1 < z1; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      54  	x2 < z2; /* { dg-warning "comparison of distinct pointer types lacks a cast" } */
      55  	// conditional expressions
      56  	(void)(1 ? x0 : z0); /* { dg-warning "pointer type mismatch in conditional expression" } */
      57  	(void)(1 ? x1 : z1); /* { dg-warning "pointer type mismatch in conditional expression" } */
      58  	(void)(1 ? x2 : z2); /* { dg-warning "pointer type mismatch in conditional expression" } */
      59  }
      60