cxx-using-declaration.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. namespace A {
  3. int VA;
  4. void FA() {}
  5. struct SA { int V; };
  6. }
  7. using A::VA;
  8. using A::FA;
  9. using typename A::SA;
  10. int main()
  11. {
  12. VA = 1;
  13. FA();
  14. SA x; //Still needs handling.
  15. }
  16. struct B {
  17. void f(char){};
  18. void g(char){};
  19. };
  20. struct D : B {
  21. using B::f;
  22. void f(int);
  23. void g(int);
  24. };
  25. void D::f(int) { f('c'); } // calls B::f(char)
  26. void D::g(int) { g('c'); } // recursively calls D::g(int)
  27. namespace E {
  28. template <typename TYPE> int funcE(TYPE arg) { return(arg); }
  29. }
  30. using E::funcE<int>; // expected-error{{using declaration cannot refer to a template specialization}}
  31. namespace F {
  32. struct X;
  33. }
  34. using F::X;
  35. // Should have some errors here. Waiting for implementation.
  36. void X(int);
  37. struct X *x;
  38. namespace ShadowedTagNotes {
  39. namespace foo {
  40. class Bar {};
  41. }
  42. void Bar(int); // expected-note{{class 'Bar' is hidden by a non-type declaration of 'Bar' here}}
  43. using foo::Bar;
  44. void ambiguity() {
  45. const Bar *x; // expected-error{{must use 'class' tag to refer to type 'Bar' in this scope}}
  46. }
  47. } // namespace ShadowedTagNotes