Dominic Chen | 184c624 | 2017-03-03 18:02:02 +0000 | [diff] [blame^] | 1 | // RUN: %clang_analyze_cc1 -std=gnu++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s |
Artem Dergachev | 78692ea | 2016-08-02 12:21:09 +0000 | [diff] [blame] | 2 | |
| 3 | // expected-no-diagnostics |
| 4 | |
| 5 | |
| 6 | bool 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. |
| 18 | bool 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 |
| 30 | bool 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. |
| 42 | bool 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 | } |