1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection\
2 // RUN:   -analyzer-checker cplusplus.Move,cplusplus.SmartPtr\
3 // RUN:   -std=c++11 -verify %s
4 
5 #include "Inputs/system-header-simulator-cxx.h"
6 
7 void clang_analyzer_warnIfReached();
8 
9 void derefAfterMove(std::unique_ptr<int> P) {
10   std::unique_ptr<int> Q = std::move(P);
11   if (Q)
12     clang_analyzer_warnIfReached(); // expected-warning{{REACHABLE}}
13   *Q.get() = 1; // no-warning
14   if (P)
15     clang_analyzer_warnIfReached(); // no-warning
16   // TODO: Report a null dereference (instead).
17   *P.get() = 1; // expected-warning {{Method called on moved-from object 'P'}}
18 }
19