1 // RUN: %clang_cc1 -std=c++1z -Wno-unused-value -verify %s
2 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify %s
7 if (int t
= 0; t
) ++t
; else --t
;
9 if (int x
, y
= 0; y
) // expected-note 2 {{previous definition is here}}
10 int x
= 0; // expected-error {{redefinition of 'x'}}
12 int x
= 0; // expected-error {{redefinition of 'x'}}
14 if (x
; int a
= 0) ++a
;
15 if (x
, +x
; int a
= 0) // expected-note 2 {{previous definition is here}}
16 int a
= 0; // expected-error {{redefinition of 'a'}}
18 int a
= 0; // expected-error {{redefinition of 'a'}}
22 b
= 2; // expected-error {{use of undeclared identifier}}
32 switch (int x
, y
= 0; y
) {
39 switch (int x
, y
= 0; y
) { // expected-note 2 {{previous definition is here}}
41 int x
= 0; // expected-error {{redefinition of 'x'}}
43 int y
= 0; // expected-error {{redefinition of 'y'}}
46 switch (x
; int a
= 0) {
51 switch (x
, +x
; int a
= 0) { // expected-note {{previous definition is here}}
53 int a
= 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
55 int a
= 0; // expected-error {{redefinition of 'a'}}
58 switch (int b
= 0; b
) {
62 b
= 2; // expected-error {{use of undeclared identifier}}
65 constexpr bool constexpr_if_init(int n
) {
66 if (int a
= n
; ++a
> 0)
72 constexpr int constexpr_switch_init(int n
) {
73 switch (int p
= n
+ 2; p
) {
83 void test_constexpr_init_stmt() {
84 constexpr bool a
= constexpr_if_init(-2);
85 static_assert(!a
, "");
86 static_assert(constexpr_if_init(1), "");
88 constexpr int b
= constexpr_switch_init(-1);
89 static_assert(b
== 1, "");
90 static_assert(constexpr_switch_init(-2) == 0, "");
91 static_assert(constexpr_switch_init(-5) == -1, "");