Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / Warray-compare-2.c
blobb3688e69b370add533078d7bbbc5ff165298b7a2
1 /* PR c++/97573 */
2 /* { dg-do compile } */
3 /* { dg-options "-Wall -Wno-array-compare" } */
5 #ifndef __cplusplus
6 # define bool _Bool
7 #endif
9 int arr1[5];
10 int arr2[5];
11 int arr3[2][2];
12 int arr4[2][2];
14 bool
15 g ()
17 bool b = arr1 == arr2; /* { dg-bogus "comparison between two arrays" } */
18 b &= arr1 != arr2; /* { dg-bogus "comparison between two arrays" } */
19 b &= arr1 > arr2; /* { dg-bogus "comparison between two arrays" } */
20 b &= arr1 >= arr2; /* { dg-bogus "comparison between two arrays" } */
21 b &= arr1 < arr2; /* { dg-bogus "comparison between two arrays" } */
22 b &= arr1 <= arr2; /* { dg-bogus "comparison between two arrays" } */
23 #ifdef __cplusplus
24 b &= +arr1 == +arr2;
25 b &= +arr1 != +arr2;
26 b &= +arr1 > +arr2;
27 b &= +arr1 >= +arr2;
28 b &= +arr1 < +arr2;
29 b &= +arr1 <= +arr2;
30 #endif
31 b &= &arr1[0] == &arr2[0];
32 b &= &arr1[0] != &arr2[0];
33 b &= &arr1[0] > &arr2[0];
34 b &= &arr1[0] >= &arr2[0];
35 b &= &arr1[0] < &arr2[0];
36 b &= &arr1[0] <= &arr2[0];
38 b &= arr3 == arr4; /* { dg-bogus "comparison between two arrays" } */
40 #if defined(__cplusplus) && __cplusplus > 201703L
41 auto cmp = arr1 <=> arr2; /* { dg-error "invalid operands" "" { target c++20 } } */
42 #endif
43 return b;