[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / SemaCXX / cxx1z-init-statement.cpp
blobeea2589ab7c62eb75751a608973c473dbe9dc0df
1 // RUN: %clang_cc1 -std=c++1z -Wno-unused-value -verify %s
2 // RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify %s
4 void testIf() {
5 int x = 0;
6 if (x; x) ++x;
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'}}
11 else
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'}}
17 else
18 int a = 0; // expected-error {{redefinition of 'a'}}
20 if (int b = 0; b)
22 b = 2; // expected-error {{use of undeclared identifier}}
25 void testSwitch() {
26 int x = 0;
27 switch (x; x) {
28 case 1:
29 ++x;
32 switch (int x, y = 0; y) {
33 case 1:
34 ++x;
35 default:
36 ++y;
39 switch (int x, y = 0; y) { // expected-note 2 {{previous definition is here}}
40 case 0:
41 int x = 0; // expected-error {{redefinition of 'x'}}
42 case 1:
43 int y = 0; // expected-error {{redefinition of 'y'}}
46 switch (x; int a = 0) {
47 case 0:
48 ++a;
51 switch (x, +x; int a = 0) { // expected-note {{previous definition is here}}
52 case 0:
53 int a = 0; // expected-error {{redefinition of 'a'}} // expected-note {{previous definition is here}}
54 case 1:
55 int a = 0; // expected-error {{redefinition of 'a'}}
58 switch (int b = 0; b) {
59 case 0:
60 break;
62 b = 2; // expected-error {{use of undeclared identifier}}
65 constexpr bool constexpr_if_init(int n) {
66 if (int a = n; ++a > 0)
67 return true;
68 else
69 return false;
72 constexpr int constexpr_switch_init(int n) {
73 switch (int p = n + 2; p) {
74 case 0:
75 return 0;
76 case 1:
77 return 1;
78 default:
79 return -1;
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, "");