brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 4660971 Raw
99 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3struct Opaque0 {};4struct Opaque1 {};5 6// Redeclarations are okay in a namespace.7namespace test0 {8  namespace ns {9    void foo(Opaque0); // expected-note 2 {{candidate function}}10  }11 12  using ns::foo;13  using ns::foo;14 15  void test0() {16    foo(Opaque1()); // expected-error {{no matching function for call}}17  }18 19  namespace ns {20    void foo(Opaque1);21  }22 23  void test1() {24    foo(Opaque1()); // expected-error {{no matching function for call}}25  }26 27  using ns::foo;28 29  void test2() {30    foo(Opaque1());31  }32 33  using ns::foo;34}35 36// Make sure we handle transparent contexts the same way.37namespace test1 {38  namespace ns {39    void foo(Opaque0); // expected-note 2 {{candidate function}}40  }41 42  extern "C++" {43    using ns::foo;44  }45 46  void test0() {47    foo(Opaque1()); // expected-error {{no matching function for call}}48  }49 50  namespace ns {51    void foo(Opaque1);52  }53 54  void test1() {55    foo(Opaque1()); // expected-error {{no matching function for call}}56  }57 58  extern "C++" {59    using ns::foo;60  }61 62  void test2() {63    foo(Opaque1());64  }65}66 67// Make sure we detect invalid redeclarations that can't be detected68// until template instantiation.69namespace test2 {70  template <class T> struct Base {71    typedef Base type;72    void foo();73  };74 75  template <class T> struct Derived : Base<T> {76    // These are invalid redeclarations, detectable only after77    // instantiation.78    using Base<T>::foo; // expected-note {{previous using decl}}79    using Base<T>::type::foo; //expected-error {{redeclaration of using decl}}80  };81 82  template struct Derived<int>; // expected-note {{in instantiation of template class}}83}84 85// Redeclarations are okay in a function.86namespace test3 {87  namespace N {88    int f(int);89    typedef int type;90  }91 92  void g() {93    using N::f;94    using N::f;95    using N::type;96    using N::type;97  }98}99