| 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 |
| 3 |
|
| 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 |
| 6 |
|
| 7 |
// expected-no-diagnostics |
| 8 |
|
| 9 |
// This reduced test case exposed a use-after-free memory bug, which was reliable |
| 10 |
// reproduced only on guarded malloc (and probably valgrind). |
| 11 |
|
| 12 |
#ifndef HEADER |
| 13 |
#define HEADER |
| 14 |
|
| 15 |
template < class _T2> struct is_convertible; |
| 16 |
template <> struct is_convertible<int> { typedef int type; }; |
| 17 |
|
| 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}} |
| 23 |
}; |
| 24 |
|
| 25 |
template <class _ForwardIterator> |
| 26 |
pair<_ForwardIterator, _ForwardIterator> __equal_range(_ForwardIterator) { |
| 27 |
return pair<_ForwardIterator, _ForwardIterator>(0, 0); // expected-error {{no matching constructor}} |
| 28 |
} |
| 29 |
|
| 30 |
template <class _ForwardIterator> |
| 31 |
pair<_ForwardIterator, _ForwardIterator> equal_range( _ForwardIterator a) { |
| 32 |
return __equal_range(a); // expected-note {{instantiation}} |
| 33 |
} |
| 34 |
|
| 35 |
class A { |
| 36 |
pair<int, int> range() { |
| 37 |
return equal_range(0); // expected-note {{instantiation}} |
| 38 |
} |
| 39 |
}; |
| 40 |
|
| 41 |
#else |
| 42 |
|
| 43 |
#endif |