1*93786da2SChandler Carruth // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes -emit-llvm -std=c++11 -o - %s | FileCheck %s 2b7e5c847SDouglas Gregor 3b7e5c847SDouglas Gregor template<typename T> 4b7e5c847SDouglas Gregor struct X0 { fX05b7e5c847SDouglas Gregor void f(T &t) { 6b7e5c847SDouglas Gregor t = 0; 7b7e5c847SDouglas Gregor } 8b7e5c847SDouglas Gregor 9b7e5c847SDouglas Gregor void g(T &t); 10b7e5c847SDouglas Gregor 11b7e5c847SDouglas Gregor void h(T &t); 12b7e5c847SDouglas Gregor 13b7e5c847SDouglas Gregor static T static_var; 14b7e5c847SDouglas Gregor }; 15b7e5c847SDouglas Gregor 16b7e5c847SDouglas Gregor template<typename T> g(T & t)17b7e5c847SDouglas Gregorinline void X0<T>::g(T & t) { 18b7e5c847SDouglas Gregor t = 0; 19b7e5c847SDouglas Gregor } 20b7e5c847SDouglas Gregor 21b7e5c847SDouglas Gregor template<typename T> h(T & t)22b7e5c847SDouglas Gregorvoid X0<T>::h(T & t) { 23b7e5c847SDouglas Gregor t = 0; 24b7e5c847SDouglas Gregor } 25b7e5c847SDouglas Gregor 26b7e5c847SDouglas Gregor template<typename T> 27b7e5c847SDouglas Gregor T X0<T>::static_var = 0; 28b7e5c847SDouglas Gregor 29b7e5c847SDouglas Gregor extern template struct X0<int*>; 30b7e5c847SDouglas Gregor test(X0<int * > xi,int * ip)31b7e5c847SDouglas Gregorint *&test(X0<int*> xi, int *ip) { 32b7e5c847SDouglas Gregor // CHECK: define available_externally void @_ZN2X0IPiE1fERS0_ 33b7e5c847SDouglas Gregor xi.f(ip); 34b7e5c847SDouglas Gregor // CHECK: define available_externally void @_ZN2X0IPiE1gERS0_ 35b7e5c847SDouglas Gregor xi.g(ip); 36b7e5c847SDouglas Gregor // CHECK: declare void @_ZN2X0IPiE1hERS0_ 37b7e5c847SDouglas Gregor xi.h(ip); 38b7e5c847SDouglas Gregor return X0<int*>::static_var; 39b7e5c847SDouglas Gregor } 40b7e5c847SDouglas Gregor 41b7e5c847SDouglas Gregor template<typename T> f0(T & t)42b7e5c847SDouglas Gregorvoid f0(T& t) { 43b7e5c847SDouglas Gregor t = 0; 44b7e5c847SDouglas Gregor } 45b7e5c847SDouglas Gregor 46b7e5c847SDouglas Gregor template<typename T> f1(T & t)47b7e5c847SDouglas Gregorinline void f1(T& t) { 48b7e5c847SDouglas Gregor t = 0; 49b7e5c847SDouglas Gregor } 50b7e5c847SDouglas Gregor 51b7e5c847SDouglas Gregor extern template void f0<>(int *&); 52b7e5c847SDouglas Gregor extern template void f1<>(int *&); 53b7e5c847SDouglas Gregor test_f0(int * ip,float * fp)54b7e5c847SDouglas Gregorvoid test_f0(int *ip, float *fp) { 55b7e5c847SDouglas Gregor // CHECK: declare void @_Z2f0IPiEvRT_ 56b7e5c847SDouglas Gregor f0(ip); 57b7e5c847SDouglas Gregor // CHECK: define linkonce_odr void @_Z2f0IPfEvRT_ 58b7e5c847SDouglas Gregor f0(fp); 59b7e5c847SDouglas Gregor } 60b7e5c847SDouglas Gregor test_f1(int * ip,float * fp)61b7e5c847SDouglas Gregorvoid test_f1(int *ip, float *fp) { 62b7e5c847SDouglas Gregor // CHECK: define available_externally void @_Z2f1IPiEvRT_ 63b7e5c847SDouglas Gregor f1(ip); 64b7e5c847SDouglas Gregor // CHECK: define linkonce_odr void @_Z2f1IPfEvRT_ 65b7e5c847SDouglas Gregor f1(fp); 66b7e5c847SDouglas Gregor } 67