summaryrefslogtreecommitdiff
path: root/test/Analysis/pointer-to-member.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/pointer-to-member.cpp')
-rw-r--r--test/Analysis/pointer-to-member.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/Analysis/pointer-to-member.cpp b/test/Analysis/pointer-to-member.cpp
index eef20627a132..039782b44b74 100644
--- a/test/Analysis/pointer-to-member.cpp
+++ b/test/Analysis/pointer-to-member.cpp
@@ -77,7 +77,8 @@ bool testDereferencing() {
namespace testPointerToMemberFunction {
struct A {
virtual int foo() { return 1; }
- int bar() { return 2; }
+ int bar() { return 2; }
+ int static staticMemberFunction(int p) { return p + 1; };
};
struct B : public A {
@@ -111,11 +112,19 @@ namespace testPointerToMemberFunction {
clang_analyzer_eval((APtr->*AFP)() == 3); // expected-warning{{TRUE}}
}
+
+ void testPointerToStaticMemberCall() {
+ int (*fPtr)(int) = &A::staticMemberFunction;
+ if (fPtr != 0) { // no-crash
+ clang_analyzer_eval(fPtr(2) == 3); // expected-warning{{TRUE}}
+ }
+ }
} // end of testPointerToMemberFunction namespace
namespace testPointerToMemberData {
struct A {
int i;
+ static int j;
};
void testPointerToMemberData() {
@@ -126,6 +135,13 @@ namespace testPointerToMemberData {
a.*AMdPointer += 1;
clang_analyzer_eval(a.i == 43); // expected-warning{{TRUE}}
+
+ int *ptrToStaticField = &A::j;
+ if (ptrToStaticField != 0) {
+ *ptrToStaticField = 7;
+ clang_analyzer_eval(*ptrToStaticField == 7); // expected-warning{{TRUE}}
+ clang_analyzer_eval(A::j == 7); // expected-warning{{TRUE}}
+ }
}
} // end of testPointerToMemberData namespace