cxx-using-declaration.cpp revision 392b3f5798a62fe038082df0a5e2244b08b917d8
1a5728872c7702ddd09537c95bc3cbd20e1f2fb09Daniel Dunbar// RUN: %clang_cc1 -fsyntax-only -verify %s 259cbea9df80273de959261401d30758ded025255John Thompson 359cbea9df80273de959261401d30758ded025255John Thompsonnamespace A { 459cbea9df80273de959261401d30758ded025255John Thompson int VA; 559cbea9df80273de959261401d30758ded025255John Thompson void FA() {} 659cbea9df80273de959261401d30758ded025255John Thompson struct SA { int V; }; 759cbea9df80273de959261401d30758ded025255John Thompson} 859cbea9df80273de959261401d30758ded025255John Thompson 959cbea9df80273de959261401d30758ded025255John Thompsonusing A::VA; 1059cbea9df80273de959261401d30758ded025255John Thompsonusing A::FA; 1159cbea9df80273de959261401d30758ded025255John Thompsonusing typename A::SA; 1259cbea9df80273de959261401d30758ded025255John Thompson 1367f44b178bf117a252594535468ed1f42ab434c1Douglas Gregorint main() 1459cbea9df80273de959261401d30758ded025255John Thompson{ 1559cbea9df80273de959261401d30758ded025255John Thompson VA = 1; 1659cbea9df80273de959261401d30758ded025255John Thompson FA(); 1759cbea9df80273de959261401d30758ded025255John Thompson SA x; //Still needs handling. 1859cbea9df80273de959261401d30758ded025255John Thompson} 1959cbea9df80273de959261401d30758ded025255John Thompson 2059cbea9df80273de959261401d30758ded025255John Thompsonstruct B { 2159cbea9df80273de959261401d30758ded025255John Thompson void f(char){}; 2259cbea9df80273de959261401d30758ded025255John Thompson void g(char){}; 2359cbea9df80273de959261401d30758ded025255John Thompson}; 2459cbea9df80273de959261401d30758ded025255John Thompsonstruct D : B { 2559cbea9df80273de959261401d30758ded025255John Thompson using B::f; 2659cbea9df80273de959261401d30758ded025255John Thompson void f(int); 2759cbea9df80273de959261401d30758ded025255John Thompson void g(int); 2859cbea9df80273de959261401d30758ded025255John Thompson}; 2959cbea9df80273de959261401d30758ded025255John Thompsonvoid D::f(int) { f('c'); } // calls B::f(char) 3059cbea9df80273de959261401d30758ded025255John Thompsonvoid D::g(int) { g('c'); } // recursively calls D::g(int) 3159cbea9df80273de959261401d30758ded025255John Thompson 3259cbea9df80273de959261401d30758ded025255John Thompsonnamespace E { 3359cbea9df80273de959261401d30758ded025255John Thompson template <typename TYPE> int funcE(TYPE arg) { return(arg); } 3459cbea9df80273de959261401d30758ded025255John Thompson} 3559cbea9df80273de959261401d30758ded025255John Thompson 3667f44b178bf117a252594535468ed1f42ab434c1Douglas Gregorusing E::funcE<int>; // expected-error{{using declaration can not refer to a template specialization}} 3759cbea9df80273de959261401d30758ded025255John Thompson 3859cbea9df80273de959261401d30758ded025255John Thompsonnamespace F { 3959cbea9df80273de959261401d30758ded025255John Thompson struct X; 4059cbea9df80273de959261401d30758ded025255John Thompson} 4159cbea9df80273de959261401d30758ded025255John Thompson 4259cbea9df80273de959261401d30758ded025255John Thompsonusing F::X; 4359cbea9df80273de959261401d30758ded025255John Thompson// Should have some errors here. Waiting for implementation. 4459cbea9df80273de959261401d30758ded025255John Thompsonvoid X(int); 4559cbea9df80273de959261401d30758ded025255John Thompsonstruct X *x; 46aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 47aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 48aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrainnamespace ShadowedTagNotes { 49aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 50aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrainnamespace foo { 51aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain class Bar {}; 52aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain} 53aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 54392b3f5798a62fe038082df0a5e2244b08b917d8Kaelyn Uhrainvoid Bar(int); // expected-note{{class 'Bar' is hidden by a non-type declaration of 'Bar' here}} 55aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrainusing foo::Bar; 56aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 57aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrainvoid ambiguity() { 58aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain const Bar *x; // expected-error{{must use 'class' tag to refer to type 'Bar' in this scope}} 59aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain} 60aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain 61aec2ac67e7190bdb88abb1d427b82ae3284ea756Kaelyn Uhrain} // namespace ShadowedTagNotes 62