diff options
Diffstat (limited to 'test/Analysis/const-method-call.cpp')
-rw-r--r-- | test/Analysis/const-method-call.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/Analysis/const-method-call.cpp b/test/Analysis/const-method-call.cpp index 17df2a016b89..a5a38929c22f 100644 --- a/test/Analysis/const-method-call.cpp +++ b/test/Analysis/const-method-call.cpp @@ -6,6 +6,14 @@ struct A { int x; void foo() const; void bar(); + + void testImplicitThisSyntax() { + x = 3; + foo(); + clang_analyzer_eval(x == 3); // expected-warning{{TRUE}} + bar(); + clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}} + } }; struct B { @@ -108,6 +116,22 @@ void checkThatContainedConstMethodDoesNotInvalidateObjects() { clang_analyzer_eval(t.in.x == 2); // expected-warning{{TRUE}} } +void checkPointerTypedThisExpression(A *a) { + a->x = 3; + a->foo(); + clang_analyzer_eval(a->x == 3); // expected-warning{{TRUE}} + a->bar(); + clang_analyzer_eval(a->x == 3); // expected-warning{{UNKNOWN}} +} + +void checkReferenceTypedThisExpression(A &a) { + a.x = 3; + a.foo(); + clang_analyzer_eval(a.x == 3); // expected-warning{{TRUE}} + a.bar(); + clang_analyzer_eval(a.x == 3); // expected-warning{{UNKNOWN}} +} + // --- Versions of the above tests where the const method is inherited --- // struct B1 { |