| 1 |
// RUN: not %clang -fsyntax-only -std=c++11 -ferror-limit=1 %s 2>&1 | FileCheck %s |
| 2 |
|
| 3 |
// Test case for PR35682. |
| 4 |
// The issue be caused by the typo correction that changes String to the |
| 5 |
// incomplete type string. The example is based on the std::pair code and |
| 6 |
// reduced to a minimal test case. When using std::pair the issue can only be |
| 7 |
// reproduced when using the -stdlib=libc++ compiler option. |
| 8 |
|
| 9 |
template <class T> class allocator; |
| 10 |
|
| 11 |
template <class charT> struct char_traits; |
| 12 |
|
| 13 |
template <class CharT, class Traits = char_traits<CharT>, |
| 14 |
class Allocator = allocator<CharT>> |
| 15 |
class basic_string; |
| 16 |
typedef basic_string<char, char_traits<char>, allocator<char>> string; |
| 17 |
|
| 18 |
template <bool, class Tp = void> struct enable_if {}; |
| 19 |
template <class Tp> struct enable_if<true, Tp> { typedef Tp type; }; |
| 20 |
|
| 21 |
template <class Tp, Tp v> struct integral_constant { |
| 22 |
static constexpr const Tp value = v; |
| 23 |
typedef Tp value_type; |
| 24 |
typedef integral_constant type; |
| 25 |
|
| 26 |
constexpr operator value_type() const noexcept { return value; } |
| 27 |
constexpr value_type operator()() const noexcept { return value; } |
| 28 |
}; |
| 29 |
|
| 30 |
template <class Tp, Tp v> constexpr const Tp integral_constant<Tp, v>::value; |
| 31 |
|
| 32 |
using true_type = integral_constant<bool, true>; |
| 33 |
using false_type = integral_constant<bool, false>; |
| 34 |
|
| 35 |
template <class Tp, class Up> struct is_same : public false_type {}; |
| 36 |
template <class Tp> struct is_same<Tp, Tp> : public true_type {}; |
| 37 |
|
| 38 |
template <class T> struct single { |
| 39 |
typedef T first_type; |
| 40 |
|
| 41 |
T first; |
| 42 |
|
| 43 |
struct CheckArgs { |
| 44 |
template <class U1> static constexpr bool enable_implicit() { |
| 45 |
return is_same<first_type, U1>::value; |
| 46 |
} |
| 47 |
}; |
| 48 |
|
| 49 |
template <class U1, |
| 50 |
typename enable_if<CheckArgs::template enable_implicit<U1>(), |
| 51 |
bool>::type = false> |
| 52 |
single(U1 &&u1); |
| 53 |
}; |
| 54 |
|
| 55 |
using SetKeyType = String; |
| 56 |
single<SetKeyType> v; |
| 57 |
|
| 58 |
// CHECK: error: unknown type name 'String'; did you mean 'string'? |
| 59 |
// CHECK: fatal error: too many errors emitted, stopping now [-ferror-limit=] |
| 60 |
// CHECK-NOT: Assertion{{.*}}failed |