diff options
Diffstat (limited to 'test/SemaCXX/warn-unsequenced.cpp')
-rw-r--r-- | test/SemaCXX/warn-unsequenced.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/SemaCXX/warn-unsequenced.cpp b/test/SemaCXX/warn-unsequenced.cpp index c7acfca6db31..54e16a5e6d50 100644 --- a/test/SemaCXX/warn-unsequenced.cpp +++ b/test/SemaCXX/warn-unsequenced.cpp @@ -1,12 +1,13 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wno-unused %s -int f(int, int); +int f(int, int = 0); struct A { int x, y; }; struct S { S(int, int); + int n; }; void test() { @@ -32,6 +33,9 @@ void test() { f(a = 0, a); // expected-warning {{unsequenced modification and access}} f(a, a += 0); // expected-warning {{unsequenced modification and access}} f(a = 0, a = 0); // expected-warning {{multiple unsequenced modifications}} + a = f(++a); // ok + a = f(a++); // ok + a = f(++a, a++); // expected-warning {{multiple unsequenced modifications}} // Compound assignment "A OP= B" is equivalent to "A = A OP B" except that A // is evaluated only once. @@ -47,6 +51,12 @@ void test() { S str2 = { a++, a++ }; // ok S str3 = { a++ + a, a++ }; // expected-warning {{unsequenced modification and access}} + struct Z { A a; S s; } z = { { ++a, ++a }, { ++a, ++a } }; // ok + a = S { ++a, a++ }.n; // ok + A { ++a, a++ }.x; // ok + a = A { ++a, a++ }.x; // expected-warning {{unsequenced modifications}} + A { ++a, a++ }.x + A { ++a, a++ }.y; // expected-warning {{unsequenced modifications}} + (xs[2] && (a = 0)) + a; // ok (0 && (a = 0)) + a; // ok (1 && (a = 0)) + a; // expected-warning {{unsequenced modification and access}} @@ -58,6 +68,8 @@ void test() { (xs[4] ? a : ++a) + a; // ok (0 ? a : ++a) + a; // expected-warning {{unsequenced modification and access}} (1 ? a : ++a) + a; // ok + (0 ? a : a++) + a; // expected-warning {{unsequenced modification and access}} + (1 ? a : a++) + a; // ok (xs[5] ? ++a : ++a) + a; // FIXME: warn here (++a, xs[6] ? ++a : 0) + a; // expected-warning {{unsequenced modification and access}} |