aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/nullptr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/nullptr.cpp')
-rw-r--r--test/Analysis/nullptr.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp
index 3f2bac11c2..c0fed87242 100644
--- a/test/Analysis/nullptr.cpp
+++ b/test/Analysis/nullptr.cpp
@@ -59,3 +59,25 @@ void zoo2() {
:"0"(*b) // expected-warning{{Dereference of null pointer}}
);
}
+
+int exprWithCleanups() {
+ struct S {
+ S(int a):a(a){}
+ ~S() {}
+
+ int a;
+ };
+
+ int *x = 0;
+ return S(*x).a; // expected-warning{{Dereference of null pointer}}
+}
+
+int materializeTempExpr() {
+ int *n = 0;
+ struct S {
+ int a;
+ S(int i): a(i) {}
+ };
+ const S &s = S(*n); // expected-warning{{Dereference of null pointer}}
+ return s.a;
+}