p11.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // rdar://problem/8540720
  3. namespace test0 {
  4. void foo() {
  5. void bar();
  6. class A {
  7. friend void bar();
  8. };
  9. }
  10. }
  11. namespace test1 {
  12. void foo() {
  13. class A {
  14. friend void bar(); // expected-error {{no matching function found in local scope}}
  15. };
  16. }
  17. }
  18. namespace test2 {
  19. void bar(); // expected-note {{'::test2::bar' declared here}}
  20. void foo() { // expected-note {{'::test2::foo' declared here}}
  21. struct S1 {
  22. friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
  23. // expected-note@-1{{'::test2::foo' declared here}}
  24. // TODO: the above note should go on line 24
  25. };
  26. void foo(); // expected-note {{local declaration nearly matches}}
  27. struct S2 {
  28. friend void foo();
  29. };
  30. {
  31. struct S2 {
  32. friend void foo(); // expected-error {{no matching function found in local scope}}
  33. };
  34. }
  35. {
  36. int foo;
  37. struct S3 {
  38. friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
  39. };
  40. }
  41. struct S4 {
  42. friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
  43. // expected-note@-1 2 {{'::test2::bar' declared here}}
  44. // TODO: the above two notes should go on line 22
  45. };
  46. { void bar(); }
  47. struct S5 {
  48. friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
  49. };
  50. {
  51. void bar();
  52. struct S6 {
  53. friend void bar();
  54. };
  55. }
  56. struct S7 {
  57. void bar() { Inner::f(); }
  58. struct Inner {
  59. friend void bar();
  60. static void f() {}
  61. };
  62. };
  63. void bar(); // expected-note {{'bar' declared here}}
  64. struct S8 {
  65. struct Inner {
  66. friend void bar();
  67. };
  68. };
  69. struct S9 {
  70. struct Inner {
  71. friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}}
  72. };
  73. };
  74. struct S10 {
  75. void quux() {}
  76. void foo() {
  77. struct Inner1 {
  78. friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
  79. friend void quux(); // expected-error {{no matching function found in local scope}}
  80. };
  81. void bar();
  82. struct Inner2 {
  83. friend void bar();
  84. };
  85. }
  86. };
  87. }
  88. }