p5.cpp 912 B

1234567891011121314151617181920212223242526272829303132333435
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace A {
  3. struct x {}; // expected-note {{candidate found by name lookup is 'A::x'}}
  4. int x; // expected-note {{candidate found by name lookup is 'A::x'}}
  5. struct y {}; // expected-note {{type declaration hidden}}
  6. struct z;
  7. void z(float);
  8. }
  9. namespace B {
  10. struct x {}; // expected-note {{candidate found by name lookup is 'B::x'}}
  11. float x; // expected-note {{candidate found by name lookup is 'B::x'}}
  12. float y; // expected-note {{declaration hides type}}
  13. void z(int);
  14. }
  15. namespace AB {
  16. using namespace A;
  17. using namespace B;
  18. }
  19. void test() {
  20. struct AB::x foo; // expected-error {{reference to 'x' is ambiguous}}
  21. int i = AB::x; // expected-error {{reference to 'x' is ambiguous}}
  22. struct AB::y bar;
  23. float f = AB::y; // expected-error {{a type named 'y' is hidden by a declaration in a different namespace}}
  24. AB::z(i);
  25. AB::z(f);
  26. }