diff options
Diffstat (limited to 'clang/test/Sema/warn-lifetime-analysis-nocfg.cpp')
-rw-r--r-- | clang/test/Sema/warn-lifetime-analysis-nocfg.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp index efa54fe662b..eaddb74e5a3 100644 --- a/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp +++ b/clang/test/Sema/warn-lifetime-analysis-nocfg.cpp @@ -201,6 +201,13 @@ void danglingReferenceFromTempOwner() { std::vector<int> getTempVec(); std::optional<std::vector<int>> getTempOptVec(); +void testLoops() { + for (auto i : getTempVec()) // ok + ; + for (auto i : *getTempOptVec()) // expected-warning {{object backing the pointer will be destroyed at the end of the full-expression}} + ; +} + int &usedToBeFalsePositive(std::vector<int> &v) { std::vector<int>::iterator it = v.begin(); int& value = *it; |