[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / crash-12631281.cpp
blobcb1ded0ce9886986c586403e8c3db999778443e0
1 // RUN: %clang_cc1 -std=c++11 %s -emit-pch -o %t.pch
2 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify
4 // RUN: %clang_cc1 -std=c++11 %s -emit-pch -fpch-instantiate-templates -o %t.pch
5 // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -include-pch %t.pch -verify
7 // expected-no-diagnostics
9 // This reduced test case exposed a use-after-free memory bug, which was reliable
10 // reproduced only on guarded malloc (and probably valgrind).
12 #ifndef HEADER
13 #define HEADER
15 template < class _T2> struct is_convertible;
16 template <> struct is_convertible<int> { typedef int type; };
18 template <class _T1, class _T2> struct pair {
19 typedef _T1 first_type;
20 typedef _T2 second_type;
21 template <class _U1, class _U2, class = typename is_convertible< first_type>::type>
22 pair(_U1&& , _U2&& ); // expected-note {{candidate}}
25 template <class _ForwardIterator>
26 pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator) {
27 return pair<_ForwardIterator, _ForwardIterator>(0, 0); // expected-error {{no matching constructor}}
30 template <class _ForwardIterator>
31 pair<_ForwardIterator, _ForwardIterator> equal_range( _ForwardIterator a) {
32 return __equal_range(a); // expected-note {{instantiation}}
35 class A {
36 pair<int, int> range() {
37 return equal_range(0); // expected-note {{instantiation}}
41 #else
43 #endif