summaryrefslogtreecommitdiff
path: root/test/SemaCXX/warn-consumed-analysis.cpp
diff options
context:
space:
mode:
authorDeLesley Hutchins <delesley@google.com>2013-10-11 22:30:48 +0000
committerDeLesley Hutchins <delesley@google.com>2013-10-11 22:30:48 +0000
commit1bf6343612e394051fffc587e6899de6901065e0 (patch)
tree679b1fc7eb7a8f21b8a68efc782b891de073fbc9 /test/SemaCXX/warn-consumed-analysis.cpp
parentf18e6e87c2fa41c2a891463483603d770a1e58a7 (diff)
downloadclang-1bf6343612e394051fffc587e6899de6901065e0.tar.gz
Consumed analysis: switch from tests_consumed/unconsumed to a general
tests_typestate attribute. Patch by chris.wailes@gmail.com. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192513 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX/warn-consumed-analysis.cpp')
-rw-r--r--test/SemaCXX/warn-consumed-analysis.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/test/SemaCXX/warn-consumed-analysis.cpp b/test/SemaCXX/warn-consumed-analysis.cpp
index 28b7794789..b11a74f95e 100644
--- a/test/SemaCXX/warn-consumed-analysis.cpp
+++ b/test/SemaCXX/warn-consumed-analysis.cpp
@@ -6,7 +6,7 @@
#define CONSUMABLE(state) __attribute__ ((consumable(state)))
#define CONSUMES __attribute__ ((consumes))
#define RETURN_TYPESTATE(state) __attribute__ ((return_typestate(state)))
-#define TESTS_UNCONSUMED __attribute__ ((tests_unconsumed))
+#define TESTS_TYPESTATE(state) __attribute__ ((tests_typestate(state)))
typedef decltype(nullptr) nullptr_t;
@@ -36,9 +36,10 @@ public:
void unconsumedCall() const CALLABLE_WHEN("unconsumed");
void callableWhenUnknown() const CALLABLE_WHEN("unconsumed", "unknown");
- bool isValid() const TESTS_UNCONSUMED;
- operator bool() const TESTS_UNCONSUMED;
- bool operator!=(nullptr_t) const TESTS_UNCONSUMED;
+ bool isValid() const TESTS_TYPESTATE(unconsumed);
+ operator bool() const TESTS_TYPESTATE(unconsumed);
+ bool operator!=(nullptr_t) const TESTS_TYPESTATE(unconsumed);
+ bool operator==(nullptr_t) const TESTS_TYPESTATE(consumed);
void constCall() const;
void nonconstCall();
@@ -146,6 +147,12 @@ void testIfStmt() {
} else {
*var; // expected-warning {{invalid invocation of method 'operator*' on object 'var' while it is in the 'consumed' state}}
}
+
+ if (var == nullptr) {
+ *var; // expected-warning {{invalid invocation of method 'operator*' on object 'var' while it is in the 'consumed' state}}
+ } else {
+ // Empty
+ }
}
void testComplexConditionals0() {