blob: 26318ac4051096a269e492c6b89889b1c19f818b [file] [log] [blame]
Artem Dergachev78692ea2016-08-02 12:21:09 +00001// RUN: %clang_cc1 -analyze -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
2
3// expected-no-diagnostics
4
5
6bool foo1(int x) {
7 start:
8 if (x != 3) {
9 ++x;
10 void *ptr = &&start;
11 goto start;
12 }
13 end:
14 return false;
15}
16
17// Targeting a different label with the address-of-label operator.
18bool foo2(int x) {
19 start:
20 if (x != 3) {
21 ++x;
22 void *ptr = &&end;
23 goto start;
24 }
25 end:
26 return false;
27}
28
29// Different target label in goto
30bool foo3(int x) {
31 start:
32 if (x != 3) {
33 ++x;
34 void *ptr = &&start;
35 goto end;
36 }
37 end:
38 return false;
39}
40
41// FIXME: Can't detect same algorithm as in foo1 but with different label names.
42bool foo4(int x) {
43 foo:
44 if (x != 3) {
45 ++x;
46 void *ptr = &&foo;
47 goto foo;
48 }
49 end:
50 return false;
51}