Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / Parser / extra-semi-resulting-in-nullstmt.cpp
blob2a10392c4c05e09e1d2b8edb0d4f955760f5fd06
1 // RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -verify %s
2 // RUN: cp %s %t
3 // RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -fixit %t
4 // RUN: %clang_cc1 -x c++ -Wextra-semi-stmt -Werror %t
6 #define GOODMACRO(varname) int varname
7 #define BETTERMACRO(varname) GOODMACRO(varname);
8 #define NULLMACRO(varname)
10 enum MyEnum {
11 E1,
15 void test() {
16 ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
19 // This removal of extra semi also consumes all the comments.
20 // clang-format off
21 ;;;
22 // clang-format on
24 // clang-format off
25 ;NULLMACRO(ZZ);
26 // clang-format on
28 {}; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
31 ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
34 if (true) {
35 ; // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
38 GOODMACRO(v0); // OK
40 GOODMACRO(v1;) // OK
42 BETTERMACRO(v2) // OK
44 BETTERMACRO(v3;) // Extra ';', but within macro expansion, so ignored.
46 BETTERMACRO(v4); // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
48 BETTERMACRO(v5;); // expected-warning {{empty expression statement has no effect; remove unnecessary ';' to silence this warning}}
50 NULLMACRO(v6) // OK
52 NULLMACRO(v7); // OK. This could be either GOODMACRO() or BETTERMACRO() situation, so we can't know we can drop it.
54 if (true)
55 ; // OK
57 while (true)
58 ; // OK
61 ; // OK
62 while (true);
64 for (;;) // OK
65 ; // OK
67 MyEnum my_enum;
68 switch (my_enum) {
69 case E1:
70 // stuff
71 break;
72 case E2:; // OK
75 for (;;) {
76 for (;;) {
77 goto contin_outer;
79 contin_outer:; // OK
85 namespace NS {};
87 void foo(int x) {
88 switch (x) {
89 case 0:
90 [[fallthrough]];
91 case 1:
92 return;
96 [[]];