65 lines · cpp
1// RUN: %check_clang_tidy %s readability-isolate-declaration %t2// XFAIL: *3 4struct S {5 int a;6 const int b;7 void f() {}8};9 10void member_pointers() {11 // FIXME: Memberpointers are transformed incorrect. Emit only a warning12 // for now.13 int S::*p = &S::a, S::*const q = &S::a;14 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability15 // CHECK-FIXES: int S::*p = &S::a;16 // CHECK-FIXES: int S::*const q = &S::a;17 18 int /* :: */ S::*pp2 = &S::a, var1 = 0;19 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability20 // CHECK-FIXES: int /* :: */ S::*pp2 = &S::a;21 // CHECK-FIXES: int var1 = 0;22 23 const int S::*r = &S::b, S::*t;24 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability25 // CHECK-FIXES: const int S::*r = &S::b;26 // CHECK-FIXES: const int S::*t;27 28 {29 int S::*mdpa1[2] = {&S::a, &S::a}, var1 = 0;30 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability31 // CHECK-FIXES: int S::*mdpa1[2] = {&S::a, &S::a};32 // CHECK-FIXES: int var1 = 0;33 34 int S ::**mdpa2[2] = {&p, &pp2}, var2 = 0;35 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability36 // CHECK-FIXES: int S ::**mdpa2[2] = {&p, &pp2};37 // CHECK-FIXES: int var2 = 0;38 39 void (S::*mdfp1)() = &S::f, (S::*mdfp2)() = &S::f;40 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability41 // CHECK-FIXES: void (S::*mdfp1)() = &S::f;42 // CHECK-FIXES: void (S::*mdfp2)() = &S::f;43 44 void (S::*mdfpa1[2])() = {&S::f, &S::f}, (S::*mdfpa2)() = &S::f;45 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability46 // CHECK-FIXES: void (S::*mdfpa1[2])() = {&S::f, &S::f};47 // CHECK-FIXES: void (S::*mdfpa2)() = &S::f;48 49 void (S::* * mdfpa3[2])() = {&mdfpa1[0], &mdfpa1[1]}, (S::*mdfpa4)() = &S::f;50 // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability51 // CHECK-FIXES: void (S::* * mdfpa3[2])() = {&mdfpa1[0], &mdfpa1[1]};52 // CHECK-FIXES: void (S::*mdfpa4)() = &S::f;53 }54 55 class CS {56 public:57 int a;58 const int b;59 };60 int const CS ::*pp = &CS::a, CS::*const qq = &CS::a;61 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability62 // CHECK-FIXES: int const CS ::*pp = &CS::a;63 // CHECK-FIXES: int const CS::*const qq = &CS::a;64}65