instantiate-member-expr.cpp revision 79cf161f178e36ce6d8aeea2a247e367b8d0fc34
1a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// RUN: %clang_cc1 -fsyntax-only -verify %s 2a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)template<typename T> 3a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)struct S { 4a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) S() { } 5a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 6a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)template<typename T> 8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)struct vector { 9a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void push_back(const T&) { int a[sizeof(T) ? -1: -1]; } // expected-error {{array with a negative size}} 10a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)}; 11a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 12a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class ExprEngine { 13a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)public: 14a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) typedef vector<S<void *> >CheckersOrdered; 15a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) CheckersOrdered Checkers; 16a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 17a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) template <typename CHECKER> 18a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void registerCheck(CHECKER *check) { 191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci Checkers.push_back(S<void *>()); // expected-note {{in instantiation of member function 'vector<S<void *> >::push_back' requested here}} 201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci } 211320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}; 221320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci 23a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)class RetainReleaseChecker { }; 24a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 25a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)void f(ExprEngine& Eng) { 26a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'ExprEngine::registerCheck<RetainReleaseChecker>' requested here}} 27a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)} 28a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) 29a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)// PR 5838 30namespace test1 { 31 template<typename T> struct A { 32 int a; 33 }; 34 35 template<typename T> struct B : A<float>, A<T> { 36 void f() { 37 a = 0; // should not be ambiguous 38 } 39 }; 40 template struct B<int>; 41 42 struct O { 43 int a; 44 template<typename T> struct B : A<T> { 45 void f() { 46 a = 0; // expected-error {{'test1::O::a' is not a member of class 'test1::O::B<int>'}} 47 } 48 }; 49 }; 50 template struct O::B<int>; // expected-note {{in instantiation}} 51} 52 53// PR7248 54namespace test2 { 55 template <class T> struct A { 56 void foo() { 57 T::bar(); // expected-error {{type 'int' cannot}} 58 } 59 }; 60 61 template <class T> class B { 62 void foo(A<T> a) { 63 a.test2::template A<T>::foo(); // expected-note {{in instantiation}} 64 } 65 }; 66 67 template class B<int>; 68} 69