61 lines · cpp
1// RUN: not %clang -fsyntax-only -std=c++11 -ferror-limit=1 %s 2>&1 | FileCheck %s2 3// Test case for PR35682.4// The issue be caused by the typo correction that changes String to the5// incomplete type string. The example is based on the std::pair code and6// reduced to a minimal test case. When using std::pair the issue can only be7// reproduced when using the -stdlib=libc++ compiler option.8 9template <class T> class allocator;10 11template <class charT> struct char_traits;12 13template <class CharT, class Traits = char_traits<CharT>,14 class Allocator = allocator<CharT>>15class basic_string;16typedef basic_string<char, char_traits<char>, allocator<char>> string;17 18template <bool, class Tp = void> struct enable_if {};19template <class Tp> struct enable_if<true, Tp> { typedef Tp type; };20 21template <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 30template <class Tp, Tp v> constexpr const Tp integral_constant<Tp, v>::value;31 32using true_type = integral_constant<bool, true>;33using false_type = integral_constant<bool, false>;34 35template <class Tp, class Up> struct is_same : public false_type {};36template <class Tp> struct is_same<Tp, Tp> : public true_type {};37 38template <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 55using SetKeyType = String;56single<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{{.*}}failed61