brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 22c6e14 Raw
136 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3namespace A {4  short i; // expected-note 2{{candidate found by name lookup is 'A::i'}}5  namespace B {6    long i; // expected-note{{candidate found by name lookup is 'A::B::i'}}7    void f() {} // expected-note{{candidate function}}8    int k;9    namespace E {} // \10      expected-note{{candidate found by name lookup is 'A::B::E'}}11  }12 13  namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}}14 15  namespace C {16    using namespace B;17    namespace E {} // \18      expected-note{{candidate found by name lookup is 'A::C::E'}}19  }20 21  void f() {} // expected-note{{candidate function}}22 23  class K1 {24    void foo();25  };26 27  void local_i() {28    char i;29    using namespace A;30    using namespace B;31    int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay32  }33  namespace B {34    int j;35  }36 37  void ambig_i() {38    using namespace A;39    using namespace A::B;40    (void) i; // expected-error{{reference to 'i' is ambiguous}}41    f(); // expected-error{{call to 'f' is ambiguous}}42    (void) j; // okay43    using namespace C;44    (void) k; // okay45    using namespace E; // expected-error{{reference to 'E' is ambiguous}}46  }47 48  struct K2 {}; // expected-note 2{{candidate found by name lookup is 'A::K2'}}49}50 51struct K2 {}; // expected-note 2{{candidate found by name lookup is 'K2'}}52 53using namespace A;54 55void K1::foo() {} // okay56 57struct K2 *k2; // expected-error{{reference to 'K2' is ambiguous}}58 59K2 *k3; // expected-error{{reference to 'K2' is ambiguous}}60 61class X { // expected-note{{candidate found by name lookup is 'X'}}62  // FIXME: produce a suitable error message for this63  using namespace A; // expected-error{{not allowed}}64};65 66namespace N {67  struct K2;68  struct K2 { };69}70 71namespace Ni {72 int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}}73}74 75namespace NiTest {76 using namespace A;77 using namespace Ni;78 79 int test() {80   return i; // expected-error{{reference to 'i' is ambiguous}}81 }82}83 84namespace OneTag {85  struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}}86}87 88namespace OneFunction {89  void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}}90}91 92namespace TwoTag {93  struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}}94}95 96namespace FuncHidesTagAmbiguity {97  using namespace OneTag;98  using namespace OneFunction;99  using namespace TwoTag;100 101  void test() {102    (void)X(); // expected-error{{reference to 'X' is ambiguous}}103  }104}105 106// PR5479107namespace Aliased {108  void inAliased();109}110namespace Alias = Aliased;111using namespace Alias;112void testAlias() {113  inAliased();114}115 116namespace N { void f2(int); }117 118extern "C++" {119  using namespace N;120  void f3() { f2(1); }121}122 123void f4() { f2(1); }124 125// PR7517126using namespace std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}127using namespace ::std; // expected-warning{{using directive refers to implicitly-defined namespace 'std'}}128 129namespace test1 {130  namespace ns { typedef int test1; }131  template <class T> using namespace ns; // expected-error {{cannot template a using directive}}132 133  // Test that we recovered okay.134  test1 x;135}136