summaryrefslogtreecommitdiff
path: root/clang/test
diff options
context:
space:
mode:
authorNicolas Lesser <blitzrakete@gmail.com>2019-01-10 19:03:33 +0000
committerNicolas Lesser <blitzrakete@gmail.com>2019-01-10 19:03:33 +0000
commitb18291aadb475c37d3317eef14b5917168643958 (patch)
tree81b4d5be9fc72810b864a6e40f50c990bd319c6e /clang/test
parent3bdcb479cea4860f693fe95a95ebc8e8c4dc3656 (diff)
Fix false positive unsequenced access and modification warning in array subscript expression.
Summary: In the [expr.sub] p1, we can read that for a given E1[E2], E1 is sequenced before E2. Patch by Mateusz Janek. Reviewers: rsmith, Rakete1111 Reviewed By: rsmith, Rakete1111 Subscribers: riccibruno, lebedev.ri, Rakete1111, hiraditya, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D50766
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/SemaCXX/warn-unsequenced-cxx17.cpp8
-rw-r--r--clang/test/SemaCXX/warn-unsequenced.cpp1
2 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-unsequenced-cxx17.cpp b/clang/test/SemaCXX/warn-unsequenced-cxx17.cpp
new file mode 100644
index 00000000000..3c221fb8d65
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unsequenced-cxx17.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wno-unused %s
+
+void test() {
+ int xs[10];
+ int *p = xs;
+ // expected-no-diagnostics
+ p[(long long unsigned)(p = 0)]; // ok
+}
diff --git a/clang/test/SemaCXX/warn-unsequenced.cpp b/clang/test/SemaCXX/warn-unsequenced.cpp
index 9e8a5b46c21..6d4468cabfe 100644
--- a/clang/test/SemaCXX/warn-unsequenced.cpp
+++ b/clang/test/SemaCXX/warn-unsequenced.cpp
@@ -81,6 +81,7 @@ void test() {
int *p = xs;
a = *(a++, p); // ok
a = a++ && a; // ok
+ p[(long long unsigned)(p = 0)]; // expected-warning {{unsequenced modification and access to 'p'}}
A *q = &agg1;
(q = &agg2)->y = q->x; // expected-warning {{unsequenced modification and access to 'q'}}