65 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -Wextra -std=c++2a -verify %s2// RUN: %clang_cc1 -fsyntax-only -Wextra-semi-stmt -std=c++2a -verify %s3// RUN: %clang_cc1 -fsyntax-only -Wempty-init-stmt -std=c++2a -verify %s4// RUN: cp %s %t5// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -fixit %t6// RUN: %clang_cc1 -x c++ -Wempty-init-stmt -std=c++2a -Werror %t7 8struct S {9 int *begin();10 int *end();11};12 13void 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 (;;) // OK24 ;25}26 27#define NULLMACRO28 29void 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 42void 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) x54 55void 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}65