diff options
| author | Alp Toker <alp@nuanti.com> | 2013-10-17 19:12:03 +0000 |
|---|---|---|
| committer | Alp Toker <alp@nuanti.com> | 2013-10-17 19:12:03 +0000 |
| commit | de0be6232bff7fcec6df6e1a1ae4560c5b9148c1 (patch) | |
| tree | d07dbaa520bbbf7d89b4cf0142c394330ba2237a /clang/test/SemaTemplate/exception-spec-crash.cpp | |
| parent | 959f04077cda4e2b4a4ffdf01351effe983d5e6e (diff) | |
| download | bcm5719-llvm-de0be6232bff7fcec6df6e1a1ae4560c5b9148c1.tar.gz bcm5719-llvm-de0be6232bff7fcec6df6e1a1ae4560c5b9148c1.zip | |
Fix missed exception spec checks and crashes
Delayed exception specification checking for defaulted members and virtual
destructors are both susceptible to mutation during iteration so we need to
process the worklists fully.
This resolves both accepts-invalid and rejects-valid issues and moreover fixes
potential invalid memory access as the contents of the vectors change during
iteration and recursive template instantiation.
This patch also adds two assertions at end of TU to ensure no specs are left
unchecked as was happenning before the fix, plus a test case from Marshall Clow
for the defaulted member crash extracted from the libcxx headers.
Reviewed by Richard Smith.
llvm-svn: 192914
Diffstat (limited to 'clang/test/SemaTemplate/exception-spec-crash.cpp')
| -rw-r--r-- | clang/test/SemaTemplate/exception-spec-crash.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/SemaTemplate/exception-spec-crash.cpp b/clang/test/SemaTemplate/exception-spec-crash.cpp new file mode 100644 index 00000000000..4d9355974c9 --- /dev/null +++ b/clang/test/SemaTemplate/exception-spec-crash.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -DCXX_EXCEPTIONS -fsyntax-only -verify %s + +template <class _Tp> struct is_nothrow_move_constructible { + static const bool value = false; +}; + +template <class _Tp> +class allocator; + +template <> +class allocator<char> {}; + +template <class _Allocator> +class basic_string { + typedef _Allocator allocator_type; + basic_string(basic_string &&__str) + noexcept(is_nothrow_move_constructible<allocator_type>::value); +}; + +class Foo { + Foo(Foo &&) noexcept = default; +#ifdef CXX_EXCEPTIONS +// expected-error@-2 {{does not match the calculated}} +#else +// expected-no-diagnostics +#endif + Foo &operator=(Foo &&) noexcept = default; + basic_string<allocator<char> > vectorFoo_; +}; |

