Add PR check to suggest alternatives to using undef (#118506)
[llvm-project.git] / clang / test / Parser / extra-semi-resulting-in-nullstmt-in-init-statement.cpp
blob7737eb02947f2f0ef39e3fc115a9538175d9a926
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
8 struct S {
9 int *begin();
10 int *end();
13 void naive(int x) {
14 if (; true) // expected-warning {{empty initialization statement of 'if' has no effect}}
17 switch (; x) { // expected-warning {{empty initialization statement of 'switch' has no effect}}
20 for (; int y : S()) // expected-warning {{empty initialization statement of 'range-based for' has no effect}}
23 for (;;) // OK
27 #define NULLMACRO
29 void with_null_macro(int x) {
30 if (NULLMACRO; true)
33 switch (NULLMACRO; x) {
36 for (NULLMACRO; int y : S())
40 #define SEMIMACRO ;
42 void with_semi_macro(int x) {
43 if (SEMIMACRO true)
46 switch (SEMIMACRO x) {
49 for (SEMIMACRO int y : S())
53 #define PASSTHROUGHMACRO(x) x
55 void with_passthrough_macro(int x) {
56 if (PASSTHROUGHMACRO(;) true)
59 switch (PASSTHROUGHMACRO(;) x) {
62 for (PASSTHROUGHMACRO(;) int y : S())