Skip to content

Commit 75e964a

Browse files
committed
Add broken test about sideeffects
1 parent 57751d1 commit 75e964a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

clang/test/Analysis/out-of-bounds-new.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -analyzer-checker=unix,core,alpha.security.ArrayBoundV2 -verify %s
1+
// RUN: %clang_analyze_cc1 -std=c++11 -Wno-array-bounds -verify %s \
2+
// RUN: -analyzer-checker=unix,core,alpha.security.ArrayBoundV2,debug.ExprInspection
3+
4+
template <typename T> void clang_analyzer_dump(T);
5+
template <typename T> void clang_analyzer_value(T);
6+
void clang_analyzer_eval(bool);
27

38
// Tests doing an out-of-bounds access after the end of an array using:
49
// - constant integer index
@@ -194,5 +199,12 @@ void using_assume_attr(int ax) {
194199

195200
void using_many_assume_attr(int yx) {
196201
[[assume(yx > 104), assume(yx > 200), assume(yx < 300)]]; // NullStmt with an attribute
197-
arrOf10[yx] = 406; // expected-warning{{Out of bound access to memory}}
202+
arrOf10[yx] = 406; // expected-warning{{Out of bounsssd access to memory}}
203+
}
204+
205+
int using_assume_attr_has_no_sideeffects(int y) {
206+
// We should not apply sideeffects of the argument of [[assume(...)]].
207+
[[assume(++y == 43)]]; // "y" should not get incremented
208+
clang_analyzer_eval(y == 42); // expected-warning {{TRUE}} expected-warning {{FALSE}} FIXME: This should be only TRUE.
209+
return y;
198210
}

0 commit comments

Comments
 (0)