Skip to content

Commit 2d6d738

Browse files
committed
add test cases
1 parent cacc5ed commit 2d6d738

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

clang/test/BoundsSafety/Sema/counted-by-member-expr-cxx.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,29 @@ class FAM_ARROW {
3939
T *tp;
4040
int fam[__counted_by(tp->count)]; // expected-error{{arrow notation not allowed for struct member in count parameter}}
4141
};
42+
43+
class FAM_THIS_ARROW_ARROW {
44+
T *tp;
45+
int fam[__counted_by(this->tp->count)]; // expected-error{{arrow notation not allowed for struct member in count parameter}}
46+
};
47+
48+
class FAM_THIS_ARROW_DOT {
49+
T t;
50+
int fam[__counted_by(this->t.count)]; // dot-expressions in counted-by is ok for FAMs
51+
};
52+
53+
class FAM_ARITHMETIC {
54+
int count;
55+
int offset;
56+
int fam[__counted_by(count - offset)]; // ok
57+
};
58+
59+
class FAM_THIS_PTR_ARITHMETIC {
60+
int count;
61+
int fam[__counted_by((this + 1)->count)]; // expected-error{{arrow notation not allowed for struct member in count parameter}}
62+
};
63+
64+
class FAM_THIS_PTR_DEREFERENCE {
65+
int count;
66+
int fam[__counted_by((*this).count)]; // expected-error{{invalid argument expression to bounds attribute}}
67+
};

0 commit comments

Comments
 (0)