[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / SemaCXX / goto2.cpp
blob9b62a22cce9190ff9057616ebc2e4f35edc42e05
1 // RUN: %clang_cc1 -fsyntax-only -verify -fcxx-exceptions -std=c++17 %s
2 // expected-no-diagnostics
4 //PR9463
5 int subfun(const char *text) {
6 const char *tmp = text;
7 return 0;
10 void fun(const char* text) {
11 int count = 0;
12 bool check = true;
14 if (check)
16 const char *end = text;
18 if (check)
22 if (check)
24 count = subfun(end);
25 goto end;
28 check = !check;
30 while (check);
32 // also works, after commenting following line of source code
33 int e = subfun(end);
35 end:
36 if (check)
37 ++count;
40 const char *text = "some text";
42 int main() {
43 const char *ptr = text;
45 fun(ptr);
47 return 0;
50 void asm_goto_try_catch() {
51 try {
52 __label__ label;
53 asm goto("" : : : : label);
54 label:;
55 } catch(...) {
56 __label__ label;
57 asm goto("" : : : : label);
58 label:;
60 if constexpr(false) {
61 __label__ label;
62 asm goto("" : : : : label);
63 label:;