Add __builtion_unreachable to vector::size(), vector::capacity()
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / compound-assignment-5.c
blob08f10606d91f096fa3c218fdac7beb45cfd71d4c
1 #include "../../gcc.dg/analyzer/analyzer-decls.h"
3 struct coord
5 int x;
6 int y;
7 };
9 /* Copying from one on-stack array to another. */
11 void test_1 (void)
13 struct coord arr_a[16];
14 struct coord arr_b[16];
15 arr_a[3].x = 5;
16 arr_a[3].y = 6;
18 arr_b[7] = arr_a[3];
20 __analyzer_eval (arr_b[7].x == 5); /* { dg-warning "TRUE" } */
21 __analyzer_eval (arr_b[7].y == 6); /* { dg-warning "TRUE" } */
24 /* Copying from an on-stack array to a global array. */
26 struct coord glob_arr2[16];
28 void test_2 (void)
30 struct coord arr[16];
31 arr[3].x = 5;
32 arr[3].y = 6;
34 glob_arr2[7] = arr[3];
36 __analyzer_eval (glob_arr2[7].x == 5); /* { dg-warning "TRUE" } */
37 __analyzer_eval (glob_arr2[7].y == 6); /* { dg-warning "TRUE" } */
40 /* Copying from a partially initialized on-stack array to a global array. */
42 struct coord glob_arr3[16];
44 void test_3 (void)
46 struct coord arr[16];
47 arr[3].y = 6;
49 glob_arr3[7] = arr[3]; // or should the uninit warning be here?
51 __analyzer_eval (glob_arr3[7].y == 6); /* { dg-warning "TRUE" } */
52 __analyzer_eval (glob_arr3[7].x); /* { dg-warning "uninitialized" "uninit" } */
55 /* Symbolic bindings: copying from one array to another. */
57 void test_4 (int i)
59 struct coord arr_a[16];
60 struct coord arr_b[16];
61 arr_a[i].x = 5;
62 arr_a[i].y = 6;
63 __analyzer_eval (arr_a[i].x == 5); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
64 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
65 __analyzer_eval (arr_a[i].y == 6); /* { dg-warning "TRUE" } */
67 arr_b[i] = arr_a[i];
69 __analyzer_eval (arr_b[i].x == 5); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
70 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
71 __analyzer_eval (arr_b[i].y == 6); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
72 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
75 /* Symbolic bindings: copying within an array: symbolic src and dest */
77 void test_5a (int i, int j)
79 struct coord arr[16];
80 arr[i].x = 5;
81 arr[i].y = 6;
83 arr[j] = arr[i];
85 __analyzer_eval (arr[j].x == 5); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
86 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
87 __analyzer_eval (arr[j].y == 6); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
88 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
91 /* Symbolic bindings: copying within an array: symbolic src, concrete dest. */
93 void test_5b (int i)
95 struct coord arr[16];
96 arr[i].x = 5;
97 arr[i].y = 6;
99 arr[3] = arr[i];
101 __analyzer_eval (arr[3].x == 5); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
102 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
103 __analyzer_eval (arr[3].y == 6); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
104 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
107 /* Symbolic bindings: copying within an array: concrete src, symbolic dest. */
109 void test_5c (int i)
111 struct coord arr[16];
112 arr[3].x = 5;
113 arr[3].y = 6;
115 arr[i] = arr[3];
117 __analyzer_eval (arr[i].x == 5); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
118 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
119 __analyzer_eval (arr[i].y == 6); /* { dg-warning "TRUE" "TRUE" { xfail *-*-* } } */
120 /* { dg-bogus "UNKNOWN" "UNKNOWN" { xfail *-*-* } .-1 } */
123 /* No info on the subregion being copied, and hence
124 binding_cluster2::maybe_get_compound_binding should return NULL. */
126 struct coord glob_arr6[16];
128 void test_6 (void)
130 struct coord arr[16];
131 arr[7] = glob_arr6[3];
133 __analyzer_eval (arr[7].x == 5); /* { dg-warning "UNKNOWN" } */
134 __analyzer_eval (arr[7].y == 6); /* { dg-warning "UNKNOWN" } */