Roman Lebedev | 377748f | 2018-11-20 18:59:05 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -fsyntax-only -Wextra -std=c++2a -verify %s |
| 2 | // RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -std=c++2a -verify %s |
| 3 | // RUN: %clang_cc1 -fsyntax-only -Wempty-init-stmt -std=c++2a -verify %s |
| 4 | // RUN: cp %s %t |
| 5 | // RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -fixit %t |
| 6 | // RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -Werror %t |
| 7 | |
| 8 | struct S { |
| 9 | int *begin(); |
| 10 | int *end(); |
| 11 | }; |
| 12 | |
| 13 | void naive(int x) { |
| 14 | if (; true) // expected-warning {{empty initialization statement of 'if' has no effect}} |
| 15 | ; |
| 16 | |
| 17 | switch (; x) { // expected-warning {{empty initialization statement of 'switch' has no effect}} |
| 18 | } |
| 19 | |
| 20 | for (; int y : S()) // expected-warning {{empty initialization statement of 'range-based for' has no effect}} |
| 21 | ; |
| 22 | |
| 23 | for (;;) // OK |
| 24 | ; |
| 25 | } |
| 26 | |
| 27 | #define NULLMACRO |
| 28 | |
| 29 | void with_null_macro(int x) { |
| 30 | if (NULLMACRO; true) |
| 31 | ; |
| 32 | |
| 33 | switch (NULLMACRO; x) { |
| 34 | } |
| 35 | |
| 36 | for (NULLMACRO; int y : S()) |
| 37 | ; |
| 38 | } |
| 39 | |
| 40 | #define SEMIMACRO ; |
| 41 | |
| 42 | void with_semi_macro(int x) { |
| 43 | if (SEMIMACRO true) |
| 44 | ; |
| 45 | |
| 46 | switch (SEMIMACRO x) { |
| 47 | } |
| 48 | |
| 49 | for (SEMIMACRO int y : S()) |
| 50 | ; |
| 51 | } |
| 52 | |
| 53 | #define PASSTHROUGHMACRO(x) x |
| 54 | |
| 55 | void with_passthrough_macro(int x) { |
| 56 | if (PASSTHROUGHMACRO(;) true) |
| 57 | ; |
| 58 | |
| 59 | switch (PASSTHROUGHMACRO(;) x) { |
| 60 | } |
| 61 | |
| 62 | for (PASSTHROUGHMACRO(;) int y : S()) |
| 63 | ; |
| 64 | } |