instantiate-call.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace N1 {
  3. struct X0 { };
  4. int& f0(X0);
  5. }
  6. namespace N2 {
  7. char& f0(char);
  8. template<typename T, typename Result>
  9. struct call_f0 {
  10. void test_f0(T t) {
  11. Result result = f0(t);
  12. }
  13. };
  14. }
  15. template struct N2::call_f0<int, char&>;
  16. template struct N2::call_f0<N1::X0, int&>;
  17. namespace N3 {
  18. template<typename T, typename Result>
  19. struct call_f0 {
  20. void test_f0(T t) {
  21. Result &result = f0(t); // expected-error {{undeclared identifier}} \
  22. expected-error {{neither visible in the template definition nor found by argument-dependent lookup}}
  23. }
  24. };
  25. }
  26. template struct N3::call_f0<int, char&>; // expected-note{{instantiation}}
  27. template struct N3::call_f0<N1::X0, int&>;
  28. short& f0(char); // expected-note {{should be declared prior to the call site}}
  29. namespace N4 {
  30. template<typename T, typename Result>
  31. struct call_f0 {
  32. void test_f0(T t) {
  33. Result &result = f0(t);
  34. }
  35. };
  36. }
  37. template struct N4::call_f0<int, short&>;
  38. template struct N4::call_f0<N1::X0, int&>;
  39. template struct N3::call_f0<int, short&>; // expected-note{{instantiation}}
  40. // FIXME: test overloaded function call operators, calls to member
  41. // functions, etc.