xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/cxx-using-declaration.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc namespace A {
4*f4a2713aSLionel Sambuc     int VA;
FA()5*f4a2713aSLionel Sambuc     void FA() {}
6*f4a2713aSLionel Sambuc     struct SA { int V; };
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc using A::VA;
10*f4a2713aSLionel Sambuc using A::FA;
11*f4a2713aSLionel Sambuc using typename A::SA;
12*f4a2713aSLionel Sambuc 
main()13*f4a2713aSLionel Sambuc int main()
14*f4a2713aSLionel Sambuc {
15*f4a2713aSLionel Sambuc     VA = 1;
16*f4a2713aSLionel Sambuc     FA();
17*f4a2713aSLionel Sambuc     SA x;   //Still needs handling.
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc struct B {
fB21*f4a2713aSLionel Sambuc     void f(char){};
gB22*f4a2713aSLionel Sambuc     void g(char){};
23*f4a2713aSLionel Sambuc };
24*f4a2713aSLionel Sambuc struct D : B {
25*f4a2713aSLionel Sambuc     using B::f;
26*f4a2713aSLionel Sambuc     void f(int);
27*f4a2713aSLionel Sambuc     void g(int);
28*f4a2713aSLionel Sambuc };
f(int)29*f4a2713aSLionel Sambuc void D::f(int) { f('c'); } // calls B::f(char)
g(int)30*f4a2713aSLionel Sambuc void D::g(int) { g('c'); } // recursively calls D::g(int)
31*f4a2713aSLionel Sambuc 
32*f4a2713aSLionel Sambuc namespace E {
funcE(TYPE arg)33*f4a2713aSLionel Sambuc     template <typename TYPE> int funcE(TYPE arg) { return(arg); }
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc using E::funcE<int>; // expected-error{{using declaration cannot refer to a template specialization}}
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc namespace F {
39*f4a2713aSLionel Sambuc     struct X;
40*f4a2713aSLionel Sambuc }
41*f4a2713aSLionel Sambuc 
42*f4a2713aSLionel Sambuc using F::X;
43*f4a2713aSLionel Sambuc // Should have some errors here.  Waiting for implementation.
44*f4a2713aSLionel Sambuc void X(int);
45*f4a2713aSLionel Sambuc struct X *x;
46*f4a2713aSLionel Sambuc 
47*f4a2713aSLionel Sambuc 
48*f4a2713aSLionel Sambuc namespace ShadowedTagNotes {
49*f4a2713aSLionel Sambuc 
50*f4a2713aSLionel Sambuc namespace foo {
51*f4a2713aSLionel Sambuc   class Bar {};
52*f4a2713aSLionel Sambuc }
53*f4a2713aSLionel Sambuc 
54*f4a2713aSLionel Sambuc void Bar(int); // expected-note{{class 'Bar' is hidden by a non-type declaration of 'Bar' here}}
55*f4a2713aSLionel Sambuc using foo::Bar;
56*f4a2713aSLionel Sambuc 
ambiguity()57*f4a2713aSLionel Sambuc void ambiguity() {
58*f4a2713aSLionel Sambuc    const Bar *x; // expected-error{{must use 'class' tag to refer to type 'Bar' in this scope}}
59*f4a2713aSLionel Sambuc }
60*f4a2713aSLionel Sambuc 
61*f4a2713aSLionel Sambuc } // namespace ShadowedTagNotes
62