1 // RUN: %clang_cc1 -analyze -analyzer-checker=core.experimental.UnreachableCode -analyzer-check-objc-mem -analyzer-checker=core.DeadStores -verify -analyzer-opt-analyze-nested-blocks -Wno-unused-value %s
3 extern void foo(int a
);
5 // The first few tests are non-path specific - we should be able to find them
7 void test(unsigned a
) {
9 a
+= 5; // expected-warning{{never executed}}
18 void test2(unsigned a
) {
24 foo(a
); // expected-warning{{never executed}}
28 void test3(unsigned a
) {
30 if (a
> 5) { // expected-warning{{never executed}}
35 // These next tests are path-sensitive
44 a
= a
+ 56; // expected-warning{{never executed}}
50 extern void bar(char c
);
52 void test5(const char *c
) {
56 bar(1); // expected-warning{{never executed}}
60 // These next tests are false positives and should not generate warnings
62 void test6(const char *c
) {
65 __builtin_unreachable(); // no-warning
68 // Compile-time constant false positives
70 enum test_enum
{ Off
, On
};
83 static unsigned a
= 0;
86 a
= 123; // no-warning
91 // Check for bugs where multiple statements are reported
92 void test9(unsigned a
) {
94 if (a
) // expected-warning{{never executed}}
95 foo(a
+ 5); // no-warning
106 // Tests from flow-sensitive version
110 goto e
; // expected-warning {{never executed}}
114 goto b
; // expected-warning {{never executed}}
115 goto a
; // expected-warning {{never executed}}