1- // RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t
2- // RUN: %check_clang_tidy -check-suffix=MACRO %s cppcoreguidelines-avoid-goto %t -- -config="{CheckOptions: { cppcoreguidelines-avoid-goto.IgnoreMacros: true }}"
1+ // RUN: %check_clang_tidy -check-suffix=,MACRO %s cppcoreguidelines-avoid-goto %t
2+ // RUN: %check_clang_tidy %s cppcoreguidelines-avoid-goto %t -- -config="{CheckOptions: { cppcoreguidelines-avoid-goto.IgnoreMacros: true }}"
33
44void noop () {}
55
66int main () {
77 noop ();
88 goto jump_to_me;
99 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
10- // CHECK-MESSAGES: [[@LINE+5]]:1: note: label defined here
11- // CHECK-MESSAGES-MACRO: [[@LINE-3]]:3: warning: avoid using 'goto' for flow control
12- // CHECK-MESSAGES-MACRO: [[@LINE+3]]:1: note: label defined here
10+ // CHECK-MESSAGES: [[@LINE+3]]:1: note: label defined here
1311 noop ();
1412
1513jump_to_me:;
@@ -19,16 +17,12 @@ jump_backwards:;
1917 goto jump_backwards;
2018 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
2119 // CHECK-MESSAGES: [[@LINE-4]]:1: note: label defined here
22- // CHECK-MESSAGES-MACRO: [[@LINE-3]]:3: warning: avoid using 'goto' for flow control
23- // CHECK-MESSAGES-MACRO: [[@LINE-6]]:1: note: label defined here
2420
2521 goto jump_in_line;
2622 ;
2723jump_in_line:;
2824 // CHECK-MESSAGES: [[@LINE-3]]:3: warning: avoid using 'goto' for flow control
2925 // CHECK-MESSAGES: [[@LINE-2]]:1: note: label defined here
30- // CHECK-MESSAGES-MACRO: [[@LINE-5]]:3: warning: avoid using 'goto' for flow control
31- // CHECK-MESSAGES-MACRO: [[@LINE-4]]:1: note: label defined here
3226
3327 // Test the GNU extension https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
3428some_label:;
@@ -141,8 +135,6 @@ void jump_out_backwards() {
141135 goto before_the_loop;
142136 // CHECK-MESSAGES: [[@LINE-1]]:9: warning: avoid using 'goto' for flow control
143137 // CHECK-MESSAGES: [[@LINE-8]]:1: note: label defined here
144- // CHECK-MESSAGES-MACRO: [[@LINE-3]]:9: warning: avoid using 'goto' for flow control
145- // CHECK-MESSAGES-MACRO: [[@LINE-10]]:1: note: label defined here
146138 }
147139 }
148140}
@@ -158,26 +150,24 @@ jump_to_me:; \
158150
159151void inside_macro_all () {
160152 macro_goto_code
161- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
162- // CHECK-MESSAGES: [[@LINE-2]]:3: note: label defined here
153+ // CHECK-MESSAGES-MACRO : [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
154+ // CHECK-MESSAGES-MACRO : [[@LINE-2]]:3: note: label defined here
163155}
164156
165157void inside_macro_label () {
166158 noop ();
167159 goto jump_to_me;
168160 // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
169- // CHECK-MESSAGES: [[@LINE+4]]:3: note: label defined here
170- // CHECK-MESSAGES-MACRO: [[@LINE-3]]:3: warning: avoid using 'goto' for flow control
171- // CHECK-MESSAGES-MACRO: [[@LINE+2]]:3: note: label defined here
161+ // CHECK-MESSAGES: [[@LINE+2]]:3: note: label defined here
172162 noop ();
173163 macro_goto_label
174164}
175165
176166void inside_macro_goto () {
177167 noop ();
178168 macro_goto_jump
179- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
180- // CHECK-MESSAGES: [[@LINE+2]]:3: note: label defined here
169+ // CHECK-MESSAGES-MACRO : [[@LINE-1]]:3: warning: avoid using 'goto' for flow control
170+ // CHECK-MESSAGES-MACRO : [[@LINE+2]]:3: note: label defined here
181171 noop ();
182172 jump_to_me:;
183173}
0 commit comments