p1-cxx11.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-show-option -verify %s
  2. template<typename T>
  3. struct set{};
  4. struct Value {
  5. template<typename T>
  6. void set(T value) {}
  7. void resolves_to_same() {
  8. Value v;
  9. v.set<double>(3.2);
  10. }
  11. };
  12. void resolves_to_different() {
  13. {
  14. Value v;
  15. // The fact that the next line is a warning rather than an error is an
  16. // extension.
  17. v.set<double>(3.2);
  18. }
  19. {
  20. int set; // Non-template.
  21. Value v;
  22. v.set<double>(3.2);
  23. }
  24. }
  25. namespace rdar9915664 {
  26. struct A {
  27. template<typename T> void a();
  28. };
  29. struct B : A { };
  30. struct C : A { };
  31. struct D : B, C {
  32. A &getA() { return static_cast<B&>(*this); }
  33. void test_a() {
  34. getA().a<int>();
  35. }
  36. };
  37. }
  38. namespace PR11856 {
  39. template<typename T> T end(T);
  40. template <typename T>
  41. void Foo() {
  42. T it1;
  43. if (it1->end < it1->end) {
  44. }
  45. }
  46. template<typename T> T *end(T*);
  47. class X { };
  48. template <typename T>
  49. void Foo2() {
  50. T it1;
  51. if (it1->end < it1->end) {
  52. }
  53. X *x;
  54. if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}}
  55. }
  56. }
  57. }