diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index ae57b84f9247c4e..26fa986810a4b8f 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -666,6 +666,15 @@ Improvements to Clang's diagnostics bool operator==(const C&) = default; }; +- Clang now emits `-Wdangling-capture` diangostic when a STL container captures a dangling reference. + + .. code-block:: c++ + + void test() { + std::vector views; + views.push_back(std::string("123")); // warning + } + Improvements to Clang's time-trace ---------------------------------- diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 0a245e2077f68ff..811265151fa0da0 100644 --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -10237,10 +10237,10 @@ def warn_dangling_pointer_assignment : Warning< InGroup; def warn_dangling_reference_captured : Warning< "object whose reference is captured by '%0' will be destroyed at the end of " - "the full-expression">, InGroup, DefaultIgnore; + "the full-expression">, InGroup; def warn_dangling_reference_captured_by_unknown : Warning< "object whose reference is captured will be destroyed at the end of " - "the full-expression">, InGroup, DefaultIgnore; + "the full-expression">, InGroup; // For non-floating point, expressions of the form x == x or x != x // should result in a warning, since these always evaluate to a constant.