[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / c-c++-common / analyzer / uninit-1.c
blob3d1021658bc469b2159aea156e85f340cdaba8c2
1 #include "analyzer-decls.h"
2 typedef __SIZE_TYPE__ size_t;
4 int test_1 (void)
6 int i; /* { dg-message "region created on stack here" } */
7 return i; /* { dg-warning "use of uninitialized value 'i'" } */
10 int test_2 (void)
12 int i; /* { dg-message "region created on stack here" } */
13 return i * 2; /* { dg-warning "use of uninitialized value 'i'" } */
16 int test_3 (void)
18 static int i;
19 return i;
22 int test_4 (void)
24 int *p; /* { dg-message "region created on stack here" } */
25 return *p; /* { dg-warning "use of uninitialized value 'p'" } */
28 int test_5 (int flag, int *q)
30 int *p; /* { dg-message "region created on stack here" } */
31 if (flag) /* { dg-message "following 'false' branch" } */
32 p = q;
34 /* There should be two enodes here,
35 i.e. not merging the init vs non-init states. */
36 __analyzer_dump_exploded_nodes (0); /* { dg-warning "2 processed enodes" } */
38 return *p; /* { dg-warning "use of uninitialized value 'p'" } */
41 int test_6 (int i)
43 int arr[10]; /* { dg-message "region created on stack here" } */
44 return arr[i]; /* { dg-warning "use of uninitialized value 'arr\\\[i\\\]'" } */
47 int test_rshift_rhs (int i)
49 int j; /* { dg-message "region created on stack here" } */
50 return i >> j; /* { dg-warning "use of uninitialized value 'j'" } */
53 int test_lshift_rhs (int i)
55 int j; /* { dg-message "region created on stack here" } */
56 return i << j; /* { dg-warning "use of uninitialized value 'j'" } */
59 int test_rshift_lhs (int i)
61 int j; /* { dg-message "region created on stack here" } */
62 return j >> i; /* { dg-warning "use of uninitialized value 'j'" } */
65 int test_lshift_lhs (int i)
67 int j; /* { dg-message "region created on stack here" } */
68 return j << i; /* { dg-warning "use of uninitialized value 'j'" } */
71 int test_cmp (int i)
73 int j; /* { dg-message "region created on stack here" } */
74 return i < j; /* { dg-warning "use of uninitialized value 'j'" } */
77 float test_plus_rhs (float x)
79 float y; /* { dg-message "region created on stack here" } */
80 return x + y; /* { dg-warning "use of uninitialized value 'y'" } */
83 float test_plus_lhs (float x)
85 float y; /* { dg-message "region created on stack here" } */
86 return y + x; /* { dg-warning "use of uninitialized value 'y'" } */
89 float test_minus_rhs (float x)
91 float y; /* { dg-message "region created on stack here" } */
92 return x - y; /* { dg-warning "use of uninitialized value 'y'" } */
95 float test_minus_lhs (float x)
97 float y; /* { dg-message "region created on stack here" } */
98 return y - x; /* { dg-warning "use of uninitialized value 'y'" } */
101 float test_times_rhs (float x)
103 float y; /* { dg-message "region created on stack here" } */
104 return x * y; /* { dg-warning "use of uninitialized value 'y'" } */
107 float test_times_lhs (float x)
109 float y; /* { dg-message "region created on stack here" } */
110 return y * x; /* { dg-warning "use of uninitialized value 'y'" } */
113 float test_divide_rhs (float x)
115 float y; /* { dg-message "region created on stack here" } */
116 return x / y; /* { dg-warning "use of uninitialized value 'y'" } */
119 float test_divide_lhs (float x)
121 float y; /* { dg-message "region created on stack here" } */
122 return y / x; /* { dg-warning "use of uninitialized value 'y'" } */
125 size_t test_builtin_strlen (void)
127 const char *ptr; /* { dg-message "region created on stack here" } */
128 return __builtin_strlen (ptr); /* { dg-warning "use of uninitialized value 'ptr'" } */
131 void test_calling_uninit_fn_ptr_1 (void)
133 void (*fn_ptr) (void); /* { dg-message "region created on stack here" } */
134 fn_ptr (); /* { dg-warning "use of uninitialized value 'fn_ptr'" } */
137 int test_calling_uninit_fn_ptr_2 (void)
139 int (*fn_ptr) (void); /* { dg-message "region created on stack here" } */
140 return fn_ptr (); /* { dg-warning "use of uninitialized value 'fn_ptr'" } */
143 extern void called_by_uninit_arg (int);
144 void test_passing_uninit_arg (void)
146 int i; /* { dg-message "region created on stack here" } */
147 called_by_uninit_arg (i); /* { dg-warning "use of uninitialized value 'i'" } */