1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
3 typedef int __attribute__((ext_vector_type(2))) V;
5 void clang_analyzer_warnIfReached(void);
6 void clang_analyzer_numTimesReached(void);
7 void clang_analyzer_eval(int);
11 V pass_through_and_set_flag(V v) {
16 V dont_crash_and_dont_split_state(V x, V y) {
18 V z = x && pass_through_and_set_flag(y);
19 clang_analyzer_eval(flag); // expected-warning{{TRUE}}
20 // FIXME: For now we treat vector operator && as short-circuit,
21 // but in fact it is not. It should always evaluate
22 // pass_through_and_set_flag(). It should not split state.
23 // Now we also get FALSE on the other path.
24 // expected-warning@-5{{FALSE}}
26 // FIXME: Should be 1 since we should not split state.
27 clang_analyzer_numTimesReached(); // expected-warning{{2}}
31 void test_read(void) {
36 clang_analyzer_eval(x[0] == 0); // expected-warning{{TRUE}}
39 V return_vector(void) {
46 int test_vector_access(void) {
47 return return_vector()[0]; // no-crash no-warning
54 // Do not crash on subscript operations into ObjC properties.
56 int out = i2.v[0]; // no-crash no-warning
58 // Check that the analysis continues.
59 clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}