Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Anders Carlsson | bc13ab2 | 2009-06-26 03:54:13 +0000 | [diff] [blame] | 2 | |
| 3 | extern "C" { void f(bool); } |
| 4 | |
| 5 | namespace std { |
| 6 | using ::f; |
| 7 | inline void f() { return f(true); } |
| 8 | } |
Douglas Gregor | 2531c2d | 2009-09-28 00:47:05 +0000 | [diff] [blame] | 9 | |
| 10 | namespace M { |
| 11 | void f(float); |
| 12 | } |
| 13 | |
| 14 | namespace N { |
| 15 | using M::f; |
| 16 | void f(int) { } // expected-note{{previous}} |
| 17 | |
| 18 | void f(int) { } // expected-error{{redefinition}} |
| 19 | } |
Douglas Gregor | 891fdae | 2009-11-15 08:11:13 +0000 | [diff] [blame] | 20 | |
| 21 | namespace N { |
| 22 | void f(double); |
| 23 | void f(long); |
| 24 | } |
| 25 | |
| 26 | struct X0 { |
| 27 | void operator()(int); |
| 28 | void operator()(long); |
| 29 | }; |
| 30 | |
| 31 | struct X1 : X0 { |
| 32 | // FIXME: give this operator() a 'float' parameter to test overloading |
| 33 | // behavior. It currently fails. |
| 34 | void operator()(); |
| 35 | using X0::operator(); |
| 36 | |
| 37 | void test() { |
| 38 | (*this)(1); |
| 39 | } |
| 40 | }; |
Anders Carlsson | ca910e8 | 2009-12-09 04:26:02 +0000 | [diff] [blame] | 41 | |
| 42 | struct A { void f(); }; |
| 43 | struct B : A { }; |
| 44 | class C : B { using B::f; }; |
Chandler Carruth | bd64729 | 2009-12-29 06:17:27 +0000 | [diff] [blame] | 45 | |
| 46 | // PR5751: Resolve overloaded functions through using decls. |
| 47 | namespace O { |
| 48 | void f(int i); |
| 49 | void f(double d); |
| 50 | } |
| 51 | namespace P { |
| 52 | void f(); |
| 53 | void g(void (*ptr)(int)); |
| 54 | using O::f; |
| 55 | void test() { |
| 56 | f(); |
| 57 | f(1); |
| 58 | void (*f_ptr1)(double) = f; |
| 59 | void (*f_ptr2)() = f; |
| 60 | g(f); |
| 61 | } |
| 62 | } |
John McCall | a113e72 | 2010-01-26 06:04:06 +0000 | [diff] [blame] | 63 | |
| 64 | // Make sure that ADL can find names brought in by using decls. |
| 65 | namespace test0 { |
| 66 | namespace ns { |
| 67 | class Foo {}; |
| 68 | |
| 69 | namespace inner { |
| 70 | void foo(char *); // expected-note {{no known conversion}} |
| 71 | } |
| 72 | |
| 73 | using inner::foo; |
| 74 | } |
| 75 | |
| 76 | void test(ns::Foo *p) { |
| 77 | foo(*p); // expected-error {{no matching function for call to 'foo'}} |
| 78 | } |
| 79 | } |
John McCall | 7edb5fd | 2010-01-26 07:16:45 +0000 | [diff] [blame] | 80 | |
| 81 | // Redeclarations! |
| 82 | namespace test1 { |
| 83 | namespace ns0 { struct Foo {}; } |
| 84 | namespace A { void foo(ns0::Foo *p, int y, int z); } |
| 85 | namespace ns2 { using A::foo; } |
| 86 | namespace ns1 { struct Bar : ns0::Foo {}; } |
| 87 | namespace A { void foo(ns0::Foo *p, int y, int z = 0); } // expected-note {{candidate}} |
| 88 | namespace ns1 { using A::foo; } |
| 89 | namespace ns2 { struct Baz : ns1::Bar {}; } |
| 90 | namespace A { void foo(ns0::Foo *p, int y = 0, int z); } |
| 91 | |
| 92 | void test(ns2::Baz *p) { |
| 93 | foo(p, 0, 0); // okay! |
| 94 | foo(p, 0); // should be fine! |
| 95 | foo(p); // expected-error {{no matching function}} |
| 96 | } |
| 97 | } |
John McCall | 78b8105 | 2010-11-10 02:40:36 +0000 | [diff] [blame] | 98 | |
| 99 | namespace test2 { |
| 100 | namespace ns { int foo; } |
| 101 | template <class T> using ns::foo; // expected-error {{cannot template a using declaration}} |
| 102 | |
| 103 | // PR8022 |
| 104 | struct A { |
| 105 | template <typename T> void f(T); |
| 106 | }; |
| 107 | class B : A { |
| 108 | template <typename T> using A::f<T>; // expected-error {{cannot template a using declaration}} |
| 109 | }; |
| 110 | } |
Douglas Gregor | 6fb0729 | 2010-12-21 07:41:49 +0000 | [diff] [blame] | 111 | |
| 112 | // PR8756 |
| 113 | namespace foo |
| 114 | { |
| 115 | class Class1; // expected-note{{forward declaration}} |
| 116 | class Class2 |
| 117 | { |
| 118 | using ::foo::Class1::Function; // expected-error{{incomplete type 'foo::Class1' named in nested name specifier}} |
| 119 | }; |
| 120 | } |